Sunday, February 03, 2008

常用Shell Script 技巧 - for loop

for loop

範例
#!/bin/bash
for X in red green blue
do
echo $X
done

例如 gzip 某個目錄 /xxx下檔案 xyz 開頭的檔案
cd /xxx

for i in `ls -1 xyz*`
do
gzip $i
done

1 comment: