1. Use Rename to modify file post-stamp
Before modification:
[Email protected]]# lltotal 2548-rw-r--r--. 1 root root 1282047 June 10:15 Stu1.doc-rw-r--r--. 1 root root 7 June 10:15 Stu2.doc-rw-r--r--. 1 root root 1282047 June 10:15 Stu3.doc-rw-r--r--. 1 root root 7 June 10:15 Stu4.doc-rw-r--r--. 1 root root 7 June 10:15 Stu5.doc
1.1. The method of modification is as follows:
find/oldboy/-maxdepth 1-type f-name "*.doc" |xargs rename doc Log
[email protected]]# LL modified:
-rw-r--r--. 1 root root 1282047 June 10:15 Stu1.log-rw-r--r--. 1 root root 7 June 10:15 Stu2.log-rw-r--r--. 1 root root 1282047 June 10:15 Stu3.log-rw-r--r--. 1 root root 7 June 10:15 Stu4.log-rw-r--r--. 1 root root 7 June 10:15 Stu5.log
2. Use for loop to modify file post-stamp
[[email protected]]# cat for.sh #!/bin/bashfor i in $ (find/oldboy/-maxdepth 1-type f-name "*.log") DOMV $i $ (echo $i |s Ed ' s#.log#.doc# ') done use Find to locate the file and give it to the I loop
2.1, before the modification:
[email protected]]# LL
-rw-r--r--. 1 root root 1282047 June 10:15 Stu1.log-rw-r--r--. 1 root root 7 June 10:15 Stu2.log-rw-r--r--. 1 root root 1282047 June 10:15 Stu3.log-rw-r--r--. 1 root root 7 June 10:15 Stu4.log-rw-r--r--. 1 root root 7 June 10:15 Stu5.log
2.2. After modification:
[email protected]]# LL
-rw-r--r--. 1 root root 1282047 June 10:15 Stu1.doc-rw-r--r--. 1 root root 7 June 10:15 Stu2.doc-rw-r--r--. 1 root root 1282047 June 10:15 Stu3.doc-rw-r--r--. 1 root root 7 June 10:15 Stu4.doc-rw-r--r--. 1 root root 7 June 10:15 Stu5.doc
3. Add a post-stamp to a file with Find and Xargs
find/oldboy/-type f |xargs-i mv {} {}.txt
This article is from the "one small step per day" blog, so be sure to keep this source http://fenyuer.blog.51cto.com/11265169/1940134
Modify file post-stamp under Linux