Reputation: 2969
Can somebody tell me one command which can rename all the files under a directory which are of the form test.c to test.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
Upvotes: 0
Views: 1555
Reputation: 753890
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
Upvotes: 3
Reputation: 263267
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/
Upvotes: 0