發表文章

目前顯示的是有「Bash Script」標籤的文章

kkbox轉檔名的Script

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #/bin/bash #將temp.txt中每行的檔名由"編號.歌名 - 歌手.副檔名" 重新命名成 "歌手 - 歌名.副檔名" export   PATH = /bin : /sbin : /usr /bin : /usr /sbin   #檢查 temp.txt 是否存在 if   [   !   -f   temp .txt   ] ;   then          echo   "temp.txt 不存在,無法執行。"          exit   1 fi   IFS = $' \n '   for   songName   in   $(cat temp.txt) do          tmpName = ${songName}          #拆成"歌名 - 歌手.副檔名"          printf   -v   tmpName   "%s"   ${tmpName#*.}          #抓歌名          printf   -v   title   "%s"   ${tmpName%% -*}          #拆今"歌手.副檔名"          printf   -v   tmpName   "%s"   ${tmpName#*- }          #抓歌手          printf   -v   artist   "%s"   ${tmpName%.*}          #抓副檔名          printf   -v   ext   "%s"   ${tmpName##*.}          #改名          mv   " ${songName} "   " ${artist}   -  ${title} . ${ext} "   done  

BashScript small note

批次建立帳號加入密碼可以用這種方式 1 echo   "password"   |   passwd   --stdin   $username

用Linux在lionfree.net上備份skynimo.twgg.org (backup)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #!/bin/bash # # This program will automatically down the files from website for backup. # Using FTP. # # HISTORY # 2014/07/16    Lim     First time to release # ############################## # 1. input FTP's Host, ID and Password.          host = "ftp.lionfree.net"          id = "lfnet_15084564"          pw = 'obv86235'   #2. what is the correct and remote working directory.          localdir = ""          remotedir = "" ############################## wget   ftp : / / $host :21 /skynimo .twgg .org / *   --ftp -user = $id   --ftp -password = $pw   -r # End of this file.

Bash Script 開頭

第一行記得要宣告使用 shell #!/bin/bash 如果要使用外部指令而不寫決對路徑的話 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH