Modify file post-stamp under Linux

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.