So I’m trying to automate a pretty tedious data gathering process from hundreds of different log files. The following script:
awk '/Loop/ { printf $4, }' log*weak*"$factor"x
will search for the line that says “Loop time of $time” and print the time
The case I’m trying to deal with now though, are when there were run time errors, and the log was never written. That is, the log file is there, but it has no text in it. The problem is that the above script will just skip over the log. I want it to output a space character (to more easily align the csv that’s being created out of all of this).
So is there a way to print $4 (the time) when /Loop/ is matched, but ” ,” when it is not?
No need the
foundvariable :After reading your comments, this simple snippet should do the trick :
It’s a ternary operator like in C.