I need to write this solution as an AWK command. I am stuck on the last question:
Write a one line shell command that will count all lines in a file called \"f
This is not a homework solution service. But I think I can give a few pointers.
One idea would be to create a counter, and then print the result at the end:
awk ' {c++} END {print c}'
I'm getting a bit confused by the terminology. First you claim that the lines should be counted, but in the examples, it says that those lines should be printed.
Now of course you could do something like this:
awk '' file.txt | wc -l
The first part will print out all lines that follow the condition, but the output will be parsed to wc -l
which is a separate program that counts the number of lines.
Now as to what the condition
should be, I leave to you. I strongly suggest that you google regular expressions and awk, it shouldn't be too hard.