I have a bash script that removes the first five lines and last nine lines on a user specified file. I need it to run on ~100 files a day, is there any way to run the script against the entire directory and then output every file to a separate directory with the same file name? Here is the script I am using.
read -e file
$file | sed '1,7d' | head -n -9 > ~/Documents/Databases/db3/$file
rm $file
I set it up to loop because of so many files but that is the core of the script.
You can do:
for file in ~/Documents/Databases/db3/*; do
[ -f "$file" ] && sed '1,7d' "$file" | head -n -9 > /out/dir/"${file##*/}"
done
Assuming the input directory is ~/Documents/Databases/db3/
and the output directory is /out/dir/
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.