【发布时间】:2012-12-04 04:06:40
【问题描述】:
我有一个 Bash 脚本循环遍历文件并屏蔽它们。这些文件被 gzip 压缩,我需要先将它们压缩,然后再将它们作为参数传递给 Python 程序,如下面的脚本所示。问题是变量$i 不会变成文件名的解压缩版本。解压前的文件名为my-log-1.c.log.gz。在如下文件上运行 gunzip 后,我想将 my-log-1.c.log 作为参数传递给 masker.sh 脚本,而不是 .gz 版本。我该怎么做?
#!bin/bash
cd /home/logs
for i in *
gunzip $i
do
python masker.py $i # python program masks files
rm $i
echo "masked_file and removed = $i"
done
【问题讨论】: