-2

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.

Software_t
  • 576
  • 1
  • 4
  • 13

2 Answers2

0

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:]]*$'

jeremysprofile
  • 10,028
  • 4
  • 33
  • 53
0

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

that other guy
  • 116,971
  • 11
  • 170
  • 194