1
2
How to use the "sed" command to remove all lines that do not end up on the pattern?
Example input:
aaa aaa.com
b b b b.txt
ccc ccc.gif
dd dd dd.txt
Looking for the pattern .txt
,
I want to get:
b b b b.txt
dd dd dd.txt
1
2
How to use the "sed" command to remove all lines that do not end up on the pattern?
Example input:
aaa aaa.com
b b b b.txt
ccc ccc.gif
dd dd dd.txt
Looking for the pattern .txt
,
I want to get:
b b b b.txt
dd dd dd.txt
2
sed '/.txt/!d' test.txt
or to replace it in your file
sed -i '/.txt/!d' test.txt
but why dont you use a simple
grep \.txt test.txt
here?
I'm doing something wrong.
`sed '/.txt/!d' $pn
printf '%s\n' "$pn" | while IFS= read -r line do printf "$line\n" done` – Creek – 2016-03-21T22:19:51.813