Exists way to remove empty lines with cat myfile | grep -w #something
?
I looking for simple way for remove empty lines from my output like in the way the presented above.
Exists way to remove empty lines with cat myfile | grep -w #something
?
I looking for simple way for remove empty lines from my output like in the way the presented above.
You can pipe your output to awk
to easily remove empty lines
cat myfile | grep -w #something | awk NF
EDIT: so... you just want cat myfile | awk NF
?
if you have to use grep, you can do grep myfile -v '^[[:blank:]]*$'
This really belongs on the codegolfing stackexchange because it's not related to how anyone would ever write a script. However, you can do it like this:
cat myfile | grep -w '.*..*'
It's equivalent to the more canonical grep .
, but adds explicit .*
s on either side so that it will always match the complete line, thereby satisfying the word boundary conditions imposed by -w