指令檔名為unzip-batch.sh#批量解壓壓縮檔,將檔案解壓到指定目錄 #!/bin/bash for zipfilenamefull in `ls ./*.zip` do #echo "$zipfilename" zipfilename=`basename $zipfilenamefull` filename=$(basename
聽人說做文本分類時處理100G的文字檔,居然不用大資料,處理方法就是用shell的split去分割成若干小檔案。 split命令 NAME split - split a file into piecesSYNOPSIS split [OPTION] [INPUT [PREFIX]]DESCRIPTION Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...;
在linux的shell中 if 語句通過關係運算子判斷運算式的真假來決定執行哪個分支。Shell 有三種 if ... else 語句: if ... fi 語句; if ... else ... fi 語句; if ... elif ... else ... fi 語句。 1) if ... else 語句 if ... else 語句的文法: if [ expression ]then Statement(s) to be
shell 指令碼中,通常會使用相對路徑來做處理,但有時候,我們也許需要用到絕對路徑。 在shell怎麼擷取一個檔案或目錄的絕對路徑呢。 也許你會立馬想到realpath(如果你寫過php的話),那麼shell支援這個命令嗎。看一下這裡你就知道了。 Realpath appears to come from debian, and is not part of coreutils,Realpath appears not to be standard issue.
#!/bin/bash function ergodic(){ for file in ` ls $1 ` do if [ -d $1"/"$file ] then ergodic $1"/"$file else echo $1"/"$file >> b fi done } INIT_PATH="/etc/httpd" ergodic $INIT_PATH