我有一個目錄,其中包含許多帶.sum擴展名的文件。 我使用下面的腳本將所有.sum文件的內容列出到temp.log文件中。當第一個.sum文件被寫入temp.log時,awk實用程序似乎給剩餘的.sum文件帶來錯誤。請幫助,我在這裏失蹤。awk:致命:無法打開文件'(沒有這樣的文件或目錄)
cd $HOME/aphp/result/${test}
for filename in *.sum
do
tempdir=$filename
awk '/Failed/' "${filename}" > temp.log
awk '/Error/' "${filename}" >> temp.log
if [ -s temp.log ]
then
mkdir -p ${scanresult}/${tempdir}
mv temp.log ${scanresult}/${tempdir}/temp.log
cd ${scanresult}/${tempdir}
mv temp.log ${tempdir}_failed.txt
else
echo Skipping ${tempdir} scanning as it is executed 100 percent with no fail or error.
rm temp.log
fi
done
錯誤:
awk: fatal: cannot open file `dss154.sum' for reading (No such file or directory)
awk: fatal: cannot open file `dss235.sum' for reading (No such file or directory)
awk: fatal: cannot open file `dss287.sum' for reading (No such file or directory)
的ls -l *的.sum
-rwxrwxrwx 1 smruti smruti 1844 Mar 25 16:23 dss103.sum
-rwxrwxrwx 1 smruti smruti 2353 Mar 25 16:40 dss154.sum
-rwxrwxrwx 1 smruti smruti 1023 Mar 25 16:43 dss235.sum
-rwxrwxrwx 1 smruti smruti 908 Mar 25 16:45 dss287.sum
-rwxrwxrwx 1 smruti smruti 867 Mar 25 16:45 dss288.sum
-rwxrwxrwx 1 smruti smruti 1064 Mar 25 16:47 dss350.sum
顯示'ls -l * .sum'的輸出 – anubhava
當前目錄中的每個文件是否都會給出該錯誤?什麼是文件的權限? – lurker
所有文件都具有讀取權限,我作爲超級用戶執行。只有第一個文件被awk讀取,剩下的文件會被跳過而出錯。 – May