#!/bin/bash
for i in $@
do
echo $i |grep '\.conf$' >/dev/null && cp $i $i.bak
done
vim $@
有些時候,我vim要加點參數,想同時打開多個文件,就使用這個
因爲有些文件夾會使用空格,所以需要把上面的腳本改寫成這樣:
#!/bin/bash
FS=$'\n'IFS=$'\n';for i in $@
do
echo "$i" |grep '\.conf$' >/dev/null && cp "$i" "$i.bak"
done
vim $@