Linux小技巧,一條命令實現查詢檔案和改名

甲骨文技術支援發表於2018-02-08

命令如下:



  1. [root@aws ~]# mkdir jiaguwen
  2. [root@aws ~]# touch jiaguwen.txt jiaguwen2.txt jiaguwen3.txt
  3. [root@aws ~]# cd jiaguwen
  4. [root@aws jiaguwen]# ls
  5. jiaguwen2.txt jiaguwen3.txt jiaguwen.txt
  6. [root@aws jiaguwen]# ls *.txt | xargs -n1 -i{} mv {} {}_bak
  7. [root@aws jiaguwen]# ls
  8. jiaguwen2.txt_bak jiaguwen3.txt_bak jiaguwen.txt_bak

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20893244/viewspace-2150961/,如需轉載,請註明出處,否則將追究法律責任。

相關文章