Renaming files with inode number [UNIX]

2019-08-12 22:19发布

问题:

I'm simply trying to rename a file by attaching an underscore and the inode number of said file before I move it to a directory.

The description is:

To avoid name conflicts in the recycle bin, change the file name to the original name followed by an underscore, followed by the inode for the file. For example, if a file named "f1" with inode 1234 were removed, the file would be named f1_1234 in the recycle bin.

Any ideas?

回答1:

It is easy if parallel is available :

ls f* | parallel 'mv {} newDir/{}_`stat -c%i {}`'