婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > Shell腳本批量添加擴展名的兩種方法分享

Shell腳本批量添加擴展名的兩種方法分享

熱門標簽:地圖標注超出范圍怎么辦 百度地圖標注圖標更換 百度地圖的地圖標注 excel地址地圖標注 杭州機器人外呼系統 佛山高德地圖標注中心 陜西電銷卡外呼系統怎么安裝 旅游地圖標注大全 東莞電銷機器人價格一覽表

方法1:

復制代碼 代碼如下:

for file in  `ls`; do mv $file $file.txt; done

方法2:

復制代碼 代碼如下:

find . -type f |xargs -i mv {} {}.txt

還有一些試驗不成功的,先記錄在此。

1.用rename命令修改后綴名,這個是最簡單最省事的辦法

復制代碼 代碼如下:

[root@demo test_rename]# ll

總計 20

-rw-r–r– 1 root root 0 09-27 00:57 rename1.log

-rw-r–r– 1 root root 0 09-27 00:57 rename2.log

-rw-r–r– 1 root root 0 09-27 00:57 rename3.log

-rw-r–r– 1 root root 0 09-27 00:57 rename4.log

-rw-r–r– 1 root root 0 09-27 00:57 rename5.log

[root@demo test_rename]# rename log txt *.log #把*.log改為*.txt

[root@demo test_rename]# ll

總計 20

-rw-r–r– 1 root root 0 09-27 00:57 rename1.txt

-rw-r–r– 1 root root 0 09-27 00:57 rename2.txt

-rw-r–r– 1 root root 0 09-27 00:57 rename3.txt

-rw-r–r– 1 root root 0 09-27 00:57 rename4.txt

-rw-r–r– 1 root root 0 09-27 00:57 rename5.txt

[root@demo test_rename]# 

2.用for、sed和mv修改后綴名

復制代碼 代碼如下:

[root@demo test_rename]# ll

總計 20

-rw-r–r– 1 root root 0 09-27 01:51 rename1.log

-rw-r–r– 1 root root 0 09-27 01:21 rename2.log

-rw-r–r– 1 root root 0 09-27 01:21 rename3.log

-rw-r–r– 1 root root 0 09-27 01:21 rename4.log

-rw-r–r– 1 root root 0 09-27 01:21 rename5.log

[root@demo test_rename]# for i in $(ls .)

> do

> mv $i $(echo $i|sed ‘s/\.log/\.txt/')

> done

[root@demo test_rename]# ll

總計 20

-rw-r–r– 1 root root 0 09-27 01:51 rename1.txt

-rw-r–r– 1 root root 0 09-27 01:21 rename2.txt

-rw-r–r– 1 root root 0 09-27 01:21 rename3.txt

-rw-r–r– 1 root root 0 09-27 01:21 rename4.txt

-rw-r–r– 1 root root 0 09-27 01:21 rename5.txt

[root@demo test_rename]#

3.用find和xargs添加后綴名

復制代碼 代碼如下:

[root@demo test_rename]# ll

總計 20

-rw-r–r– 1 root root 0 09-27 02:20 rename1

-rw-r–r– 1 root root 0 09-27 02:20 rename2

-rw-r–r– 1 root root 0 09-27 02:20 rename3

-rw-r–r– 1 root root 0 09-27 02:20 rename4

-rw-r–r– 1 root root 0 09-27 02:20 rename5

[root@demo test_rename]# find . -type f |xargs -i mv {} {}.txt

[root@demo test_rename]# ll

總計 20

-rw-r–r– 1 root root 0 09-27 02:20 rename1.txt

-rw-r–r– 1 root root 0 09-27 02:20 rename2.txt

-rw-r–r– 1 root root 0 09-27 02:20 rename3.txt

-rw-r–r– 1 root root 0 09-27 02:20 rename4.txt

-rw-r–r– 1 root root 0 09-27 02:20 rename5.txt

[root@demo test_rename]#

標簽:雅安 朝陽 南充 西藏 延邊 隨州 青島 通遼

巨人網絡通訊聲明:本文標題《Shell腳本批量添加擴展名的兩種方法分享》,本文關鍵詞  Shell,腳本,批量,添加,擴展名,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Shell腳本批量添加擴展名的兩種方法分享》相關的同類信息!
  • 本頁收集關于Shell腳本批量添加擴展名的兩種方法分享的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 黎城县| 穆棱市| 望城县| 三亚市| 定安县| 清新县| 尤溪县| 家居| 开化县| 富源县| 宜宾县| 洞头县| 乾安县| 甘德县| 黄浦区| 永清县| 佛冈县| 柯坪县| 新疆| 江阴市| 靖边县| 石门县| 仙桃市| 鄂托克前旗| 锡林郭勒盟| 安阳市| 昭苏县| 大化| 河西区| 石河子市| 大邑县| 华坪县| 松原市| 湄潭县| 汽车| 芜湖市| 北海市| 长寿区| 固原市| 关岭| 呼图壁县|