Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

new line separator for each grep result sh script [closed]

Tags:

linux

shell

unix

sh

Is there a way to have each result of grep followed by newline for example if the result of grep is:

1
2
3

I need it to be:

1

2

3
like image 354
Yo Al Avatar asked Aug 19 '13 16:08

Yo Al


People also ask

How do you grep a blank line in Unix?

To match empty lines, use the pattern ' ^$ '. To match blank lines, use the pattern ' ^[[:blank:]]*$ '. To match no lines at all, use an extended regular expression like ' a^ ' or ' $a '.


1 Answers

grep "pattern" /path/to/file | awk '{print $0,"\n"}'
like image 139
jtravaglini Avatar answered Sep 25 '22 16:09

jtravaglini