Bash Script changing the output file for every file
问题 I'm trying to use a command on everyfile .log in a folder but I can't understand how to change the output file for every file in the folder. #!/bin/bash N="0" for i in "*.log" do echo "Processing $f file..." cat $i | grep "test" | awk '/show/ {a = $1} !/show/{print a,$6}' > "log$N.txt" done How can i increment the counter for log$n.txt? 回答1: It's bad practice to write shell loops just to process text (see https://unix.stackexchange.com/questions/169716/why-is-using-a-shell-loop-to-process