If your filenames contain no whitepace and you don't have any subdirectories, you can use a simple for
loop:
$ for FILENAME in *; do mv $FILENAME Unix_$FILENAME; done
Otherwise use the convenient rename
command (which is a perl script) - although it might not be available out of the box on every Unix (e.g. OS X doesn't come with rename
).
A short overview at debian-administration.org:
If your filenames contain whitespace it's easier to use find
, on Linux the following should work:
$ find . -type f -name '*' -printf "echo mv '%h/%f' '%h/Unix_%f
'" | sh
On BSD systems, there is no -printf
option, unfortunately. But GNU findutils should be installable (on e.g. Mac OS X with brew install findutils
).
$ gfind . -type f -name '*' -printf "mv "%h/%f" "%h/Unix_%f"
" | sh
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…