N
N
niocncn2015-06-24 15:46:57
Command line
niocncn, 2015-06-24 15:46:57

How to massively rename files in a folder in Shell using a regular expression?

Can you please tell me how to rename files from arg_* to exp_* in a certain folder using find and mv?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xibir, 2015-06-24
@niocncn

#!/bin/bash
for f1 in `find /temp -name 'arg_*'`; do
   f2=${f1/arg_/exp_}
   echo "$f1 -> $f2"
   mv $f1 $f2
done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question