Parsing via sed issue

sorry I messed up the last post with too many mistakes and corrections so I closed it and opening a new one which should be clear to everyone .my apologies to the admins.

I am using sun solaris and Linux , what I want is SED to print any string (or output it to a file preferably) that does not have either "01","03","05","07","10" or "11" on the 9th and 10th position .
e.g from the file below I only want these three lines

433483433339
167710001710
167730600000
$cat a.txt
 000000001000
 433483433339 <<< print this since 33 is at 9th and 10th pos
 121121211100 
 167710001710 <<< print this since 17 is at 9th and 10th pos
 167735250310
 167735260510
 167735280710
 167730600000 <<< print this since 00 is at 9th and 10th pos

hope I am clear this time.
thanks

This is done with a simple rule. sed will per default print every line in the input file, so we just have to "delete" the lines we are not interested in.

sed '/^........0[1357]/d' /your/input/file

Notice that this does not address the lines with "10" and "11". We will get to this but first let us have a look at the regular expression:

/^........0[1357]/

It says: "^" is the beginning of line, so the beginning of line, followed by 8 characters ("." is "any character), followed by a "0". This is followed by a character class: "[1357]" means any one (but only one) character of the mentioned set. So in fact it is a convenient way of saying either "01" or "03" or "05" or "07".

The following list of commands - in this case only one command, the "d" - is executed and so these lines do not get printed, all others do.

We have left out two more types of lines you also wanted to exclude: "10" and "11" in 9th-10th position. It would be possible to put that all into one complex regex, but it is far easier (and, in my humble opinion, easier to read) to simply have two rules instead of one. Therefore:

sed -n '/^........0[1357]/d
        /^........1[01]/d' /your/input/file

Which should do what you want. Notice that sed does not change your input file so deleting lines only affects the output, not your source. If you want to lastingly change your inut you have to do it in two steps: let sed write to a different output file, then overwrite the source with this:

sed -n '/^........0[1357]/d
        /^........1[01]/d' /your/input/file > /some/output
mv /some/output /your/input/file

I hope this helps.

bakunin

@bakunin: I'm afraid the -n option suppresses ANY printout regardless of lines being deleted (by the regexes found) or not. With the -n removed the solutions is close to the ones proposed in the requestor's other thread. Please continue discussions over there. This duplicate thread is closed.