我有一個名爲/input/temp
的文件夾。在文件夾裏面我有很多文件。我需要找到Article_????_test_?????????.txt
模式的文件,並按照以下格式進行替換。Unix shell腳本查找文件並按模式替換名稱
Article_????_?????????.txt
下面是我試過和不工作的代碼:
echo "Please provide the file name Corresponding to DC..."
read file
ls $HOME/*.txt | grep $file
if [ $? -eq 0 ]
find . $file '*_Test_*' -exec bash -c 'mv $0 ${0/_Test/ }' {} \;
if [ $? -eq 0 ]
find . $file -name "*.txt" -exec bash -c "mv {} \`echo {} | sed -e 's/[_TEST_]/_/g'\`" \;
then
我得到以下錯誤:
find: 0652-083 Cannot execute bash:: A file or directory in the path name does not exist.
find: 0652-083 Cannot execute bash:: A file or directory in the path name does not exist.
Bash可以不是我的平臺上執行。
你正在使用什麼外殼?它是什麼系統? – slhck