Tuesday, 1 May 2018
linux - grep two strings from a file and write into a txt
Answer
Answer
Could you please help me how to grep two strings (or the whole lines) from one file and write them on the same line in output file?
grep -e "string1 string2" inputfile > output.txt doesn't work
for one string it works:
grep -e "string1" inputfile > output.txt
thx!
Answer
Change your grep command like below,
grep -o 'string1\|string2' file | paste - - > out.txt
This writes string1 string2
in a single line on out.txt
Subscribe to:
Post Comments (Atom)
casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV
In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...
-
The whole error output being: LNK2019 unresolved external symbol wWinMain referenced in function "int __cdecl __scrt_common_main_seh(vo...
-
I recently used canvas to conert images to webp, using : const dataUrl = canvas.toDataURL('image/webp'); But this takes a lots of ti...
-
I have come across CORS issues multiple times and can usually fix it but I want to really understand by seeing this from a MEAN stack paradi...
No comments:
Post a Comment