How to remove lines from text file not starting with certain characters (sed or grep) -
how delete lines in text file not start characters #, & or *? i'm looking solution using sed or grep.
deleting lines:
with grep
from http://lowfatlinux.com/linux-grep.html :
the grep command selects , prints lines file (or bunch of files) match pattern.
i think can this:
grep -v '^[\#\&\*]' yourfile.txt > output.txt you can use sed same thing (check http://lowfatlinux.com/linux-sed.html ):
sed '^[\#\&\*]/d' yourfile.txt > output.txt it's decide
filtering lines:
my mistake, understood wanted delete lines. if want "delete" other lines (or filter lines starting specified characters), grep way go:
grep '^[\#\&\*]' yourfile.txt > output.txt
Comments
Post a Comment