bash - Sed delete lines with more than one word, excluding a search term -
i'm trying write sed command search file, , delete lines in file have more 1 word. however, need exclude deleting line starts particular symbol (going "[")
this have far (this not including code exclude line, delete lines more 1 word):
sed -e '/^\s*\s+\s*$/!d' $1
i wanted go exclude searching lines start left bracket ("["):
sed -e '/a/!d/^\s*\s+\s*$/!d' $1
however, i'm getting error:
sed: -e look #1, char 6: characters after command
i'm sure it's little , ridiculous i'm missing. able help out this? cheers.
an awk
command simpler:
awk 'nf<2 || /(^| )\[/' file
this awk
print lines have less 2 words or word starting [
bash unix sed
No comments:
Post a Comment