Issue
I am running a command and filtering out multiple words using egrep but output is showing up in multiple lines, is there a way i can get the output in a single line with particular set of matched words.
egrep -n "name|recovery"
currently getting output as
6: "name": "7660",
27: "recovery": "2020-08-04",
40: "name": "7667708",
61: "recovery": "2020-08-03",
74: "name": "7660271",
95: "recovery": "2020-08-02",
Required output
1: "name": "7660", "recovery": "2020-08-04"
2: "name": "7667708", recovery": "2020-08-03"
3: "name": "7660271", "recovery": "2020-08-02"
Solution
You can pipe several commands to achieve that.
<<your command>> | cut -d: -f2- | sed '{N;s/,\n/,/;}' | grep -n '^'
Answered By - malarres