Rudi's sed is not returning me anything
$ type a.txt
000000001000
433483433339
121121211100
167710000110
167735250310
167735260510
167735280710
167735301010
167735431010
167735451010
167750000010
167710101110
167730691110
167730611111
$ sed -E "/^[0-9]{8}(0[1357]|1[01])/!d" a.txt
$
------ Post updated at 10:39 PM ------
open VMS .. almost same to other other operating systems.
------ Post updated at 10:41 PM ------
sorry i said it wrong earlier. . i want sed
to notify me for any violating record. that's the goal
------ Post updated at 10:43 PM ------
sorry for making a mistake in my original explaination , i corrected it .. i just want sed to output the violating records if any
------ Post updated at 10:55 PM ------
anotehr example to clear things up , from this file i want sed to output
000000000000
433483433339
because both of them do not have either 01,03,05,07,10,11 at 9th and 10th position
$ type a.txt
000000001000
000000000000
433483433339
121121211100
167710000110
167735250310
167735260510
167735280710
167735301010
167735431010
167735451010
167750000010
167710101110
167730691110
167730611111
------ Post updated at 11:00 PM ------
i am stuck with production issue need help urgently .
Don you said finding 01,03,05,07,10,11 at 9th an 10th position in a string is easy .. can you give me sed command for it please?
------ Post updated at 11:08 PM ------
I tried Rudi's command on sun solaris, Linux . .also not working .
If you can give me this solution on solaris or Linux its also fine for me
oracle$ sed -E '/^[0-9]{8}(0[1357]|1[01])/!d'
sed: illegal option -- E
oracle$ uname -a
SunOS 5.11 11.3 sun4v sparc sun4v
$
[oracle ~]$ uname -a
Linux 004160PZ000 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:15 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux
[oracle ~]$ sed -E '/^[0-9]{8}(0[1357]|1[01])/!d' a.txt
sed: invalid option -- E
------ Post updated at 11:47 PM ------
[quote="rudic
in your regex, you want 00
in positions 9 and 10. and, you may want to reread the regex documentation, as ( man regex
): so your bracket expr. seems to have too large a list, including 0
and ,
. on top, you are deleting the matching lines, so reverse the effect. try instead:
sed '/^[0-9"]
\{8\}\(0[1357]\|1[01]\)/!d' file
or, for better readability
sed -E '/^[0-9]{8}(0[1357]|1[01])/!d' file
[/quote]
I tried your command on unix and its returning me the strings that have valid numbers at 9th and 10th position e.g "01","03","05","07","10","11" ,
I want only the three records from this file that have "33" ,"17" and "00" at 9th and 10th position.
operating system is sun solaris and Linux .
oracle:$ sed '/^[0-9]\{8\}\(0[1357]\|1[01]\)/d' a.txt
000000001000
433483433339 <<< want this to be spitted out by sed 33 at 9th n 10th pos
121121211100
167710001710 <<< want this to be spitted out by sed 17 at 9th and 10th pos
167735250310
167735260510
167735280710
167735301010
167735431010
167735451010
167710101110
167730691110
167730600000 <<< want this to be spitted out by sed 00 at 9th and 10th pos