Renaming files with inode number [UNIX]

2019-08-12 22:00发布

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条回答
Anthone
2楼-- · 2019-08-12 22:30

It is easy if parallel is available :

ls f* | parallel 'mv {} newDir/{}_`stat -c%i {}`'
查看更多
登录 后发表回答