Quantcast
Channel: grep pattern and the content after that, and remove others - Unix & Linux Stack Exchange
Browsing index pages (2 articles)
↧

grep pattern and the content after that, and remove others

I'm having a problem to grep specific keyword and its content. This is sample file, the actual file is larger than this. Example user@linux:~$ cat url.txt abcrandomtextdef another random text...

View Article


Answer by Stephen Harris for grep pattern and the content after that, and...

sed would seem to be the right task for this: % sed -n 's/.* \(iwantthis\) .* \(url=[^ ]*\) .*/\1 \2/p' url.txt iwantthis url=https://www.google.com iwantthis url=yahoo.com How this works: -n -- only...

View Article

Browsing index pages (2 articles)


Latest Images