Using sed to eliminate all lines that do not match the desired form -


i have single column csv looks this:

kfig kunv k~lk k7rt 3vgt 

some of datapoints garbled in transmission. need keep entries begin capital letter, other 3 digits capital letter or number. example, in list above have delete k~lk , 3vgt.

i know delete capital letters can write

sed -n '/[a-z]\{4,\}/p' 

i want adjust last 3 digits capital letters or numbers. appreciated.

just use:

sed -n '/[a-z][a-z0-9]\{3,\}/p' 

however, if these identifiers there in file, propose following command (it assure whole line matched, reject example identifiers more 4 characters long):

sed -n '/^[a-z][a-z0-9]\{3\}$/p' 
  • ^ means "match zero-length string @ beginning of line";
  • \{3\} means "match 3 occurences of previous atom", previous atom being [a-z0-9];
  • $ means "match zero-length string @ end of line".

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -