I need a command to rename all files in the current working directory, in a way that the new filename will be the same as the old, but including a suffix corresponding to the number of lines of the original files (e.g. if the file f
has 10 lines then it should be renamed to f_10
).
Here's my (non-working) attempt:
linenum=$(wc -l); find * -type f | grep -v sh | rename 's/^/ec/'*
Best Answer
How about:
For example:
If you want to keep extensions (if present), use this instead: