我有一个包含所有tgz
文件的目录。目前,我有我运行会已更新:Bash脚本提取目录中的所有.tgz
- 您可以在目录中第一个参数的脚本
- 提取
tgz
cd
到提取的文件夹- ,然后运行我的负载脚本
- 并继续下一个tgz ..
如下所示。
目前这个脚本的工作,但如果有人不仅仅是目录名称(例如,./myScript /全/路径/到/目录)
dirname=$1
cur_dir=`pwd`
echo The directory you are about to extract is $dirname
echo $(ls ${cur_dir}/${dirname}/*.tgz)
echo Your current directory is ${cur_dir}
for tgz in $(ls ${cur_dir}/${dirname}/*.tgz) ; do # <---- I think there is a better way of doing this please advise
echo the tgz you are about to extract now is ${tgz}
cd ${dirname}; #cd into input directory
tar -xvzf ${tgz}; #extract tgz
cd ${tgz%%.tgz}; #cd into the folder you extracted
loadItExit; #run my other script to load
cd ../..; #move up two levels back to original path
done
'for fname in $ {FNAME%/ *}/* TGZ。 do'将循环到第一个给定文件的目录中的所有'* .tgz'。 – Kellerspeicher