日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Shell脚本实战之文件批量创建和修改

發布時間:2025/4/16 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Shell脚本实战之文件批量创建和修改 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Shell腳本實戰之文件批量創建和修改

  • 一、腳本要求
  • 二、腳本內容
  • 三、腳本運行結果

一、腳本要求

1.所有操作在/python下
2.批量創建12個以py后綴結尾的文件,文件名中必須包含_hcip,文件名除了_hcip固定字符串外,文件名還包含8個小寫隨機的字符。
3.創建的12個文件后綴名改為大寫的PY,固定字符串改為_hcie

二、腳本內容

#!/bin/bash ########################################################## #File Name:create_file.sh #Version:V1.0 #Aurhor: #Emali: #Created Time:2021-06-15 02:56:59 #Description: create files & modify files ##########################################################if [ -d /python ];thencd /python elsemkdir /pythoncd /python fi for i in {1..12} dofile_name=$(echo $RANDOM |md5sum |cut -c 1-8)touch ${file_name}_hcip.py donefor files in $(ls /python) dofile1=$(echo $files |cut -d '_' -f1)mv $files ${file1}_hcie.PY done

三、腳本運行結果

[root@control python]# /scripts/create_file.sh [root@control python]# ll total 0 -rw-r--r-- 1 root root 0 Jun 15 04:26 4272db00_hcie.PY -rw-r--r-- 1 root root 0 Jun 15 04:26 51989a58_hcie.PY -rw-r--r-- 1 root root 0 Jun 15 04:26 75075364_hcie.PY -rw-r--r-- 1 root root 0 Jun 15 04:26 7a272319_hcie.PY -rw-r--r-- 1 root root 0 Jun 15 04:26 7d76af2f_hcie.PY -rw-r--r-- 1 root root 0 Jun 15 04:26 977e73d6_hcie.PY -rw-r--r-- 1 root root 0 Jun 15 04:26 9e4386a0_hcie.PY -rw-r--r-- 1 root root 0 Jun 15 04:26 a35d5337_hcie.PY -rw-r--r-- 1 root root 0 Jun 15 04:26 b9cb6458_hcie.PY -rw-r--r-- 1 root root 0 Jun 15 04:26 b9d3349e_hcie.PY -rw-r--r-- 1 root root 0 Jun 15 04:26 c3e589a2_hcie.PY -rw-r--r-- 1 root root 0 Jun 15 04:26 e4f82be8_hcie.PY

總結

以上是生活随笔為你收集整理的Shell脚本实战之文件批量创建和修改的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。