将多个文件从不同目录传递到for循环时发生错误

时间:2019-03-28 20:10:47

标签: for-loop unix

你们可以检查以下消息,并向我提供任何解决方案或提示来解决for循环变量的问题。

我具有以下格式的文件:

/directory/file1.gz -> gunzip file1, it will be in ascll format
/directory/file2.gz -> gunzip file2, but the file2 still in gzip format

为解决这个问题,我在下面写了一些小脚本:

for f in ./ETF_Directories_*/*;
do
if file -z "$f" | grep -i ascii
then
echo "file is in ascii format"
else
gunzip "$f"
//**If the file is not in ascii format I mean the second case I want to 
move this gunziped file to .gz. So that it will in single .gz format, but 
I need command to write, or hint on how to use "mv" command to achieve 
what I needed**//
fi
done

1 个答案:

答案 0 :(得分:0)

StartLockTask()将删除gunzip x.gz,因此,当.gz$f时,扩展名丢失并且找不到something.gz