one liner shell script
Can somebody tell me one command which can rename all the files under a directory which are of the form test.c to t开发者_运维问答est.cc without using piping and redirection.
I have written a shell script which contains a loop and does the same work:
for i in *.c;
do
mv $i ${i%c}cc
done
find dirname -iname "*.c" -exec mv "{}" "{}"c \;
What's wrong with:
for i in *.c; do mv $i ${i%c}cc; done
It is one line - not even a very long one...
Alternatively, on Linux, there is a rename
command:
rename .c .cc *.c
mmv should do the trick.
If you have the rename
command:
rename .c .cc *.c
From the man page:
The rename command is part of the util-linux-ng package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/
精彩评论