我正在學習 shell 腳本,我編寫了兩個腳本,一個將多個文件一次復製到一個文件夾中,如果該文件夾不存在,它會創建它,就像一個魅力!您可以使用它 :D 和另一個移動它們的,我的意思是剪切和粘貼 :)
複印:
#!/bin/bash
if [ ! -e "$2" ]
then
mkdir $2
fi
if [ "$3" ]; then
cp -rn $1/*.$3 $2
echo "Copying *.$3 done!"
else
cp -rn $1/*.* $2
echo 'Copying done!'
fi
移動:
#!/bin/bash
if [ ! -e "$2" ]
then
mkdir $2
fi
if [ $3 ]; then
mv -i $1/*.$3 $2
echo "Moving *.$3 done!"
else
mv -i $1/*.* $2
echo 'Moving done!'
fi
我希望能夠像系統中任何地方的任何其他 shell 命令(例如 ls、ping、cd...)一樣使用它們。我怎樣才能做到這一點?謝謝!
你需要
copymany
和movemany
copymany
和movemany
文件放在一個文件夾中,也許~/bin
$PATH
環境變量中,例如export PATH=$PATH:$HOME/bin
,在您的.bashrc
或.zshrc
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句