Iterating over files, save the last line of the file and the filename on a text file via STDOUT and pipe?

If I interpret your question correctly, you simply want a way to execute a command on a bunch of files and then store both the name of the file and the last line of the output of the command. This should work.

If I interpret your question correctly, you simply want a way to execute a command on a bunch of files and then store both the name of the file and the last line of the output of the command. This should work: : > output # clear out the output file for file in Test_Basic_*. Scala; do printf "$file: " >> output scalac ... | awk 'END { print }' >> output done.

Exactly what I want, thousand thanks William you saved me the day and I learned the 'printf' command. – Matthias Guenther Jan 28 '11 at 14:37 You can move the redirection to the end and you won't have to clear the file first: for ... done > output – Dennis Williamson Jan 28 '11 at 18:30.

You only get the literal "$REPORT" because your awk script is enclosed in single quotes, which prevents the shell's substitution of the REPORT variable. Try this: scalac ... "$REPORT" | awk -v filename="$REPORT" 'END {print filename; print}' >> output The -v option sets an awk variable named filename to hold the value of the shell's REPORT variable. Also, it's a good rule of thumb to always quote shell variables (unless you specifically want the side effects of omitting them).

Another option would be to use the ENVIRON awk variable. ... | awk 'END { print ENVIRON"SHELL"; print }' – jamessan Jan 28 '11 at 14:43 @jamessan, yes but you'd have to export the variable first. – glenn jackman Jan 28 '11 at 15:19.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions