Help with Sed

I am working on a file with specific timestamps.

I want to delete all the lines above the timestamp 18:31. I tried using the following command but it deleted 18:31 also.

sed '1,/18:[0-9][0-9]/d' <file-name>

Some quick help will be appreciated !!!!!! :slight_smile:

sed -e '1,/18:/d' -e'/18:/d' filename

thanks for the reply but it deleted the timestamp starting with 18:, i want to retain all the timestamp starting with 18:

I didn't read your requirement properly.
Try this

sed -n '/18:/,$ p' filename

Thanks a lot. I am not that good with regex :smiley:

anbu, this is something that's I've been looking to do for awhile but couldnt find a simple way to do it.

Can you please explain what that command is doing so I can fit it to my needs?

sed -n '/18:/,$ p' filename

-n --> Displays only those lines specified by the "p" command.
/18:/,$ --> Range of lines from pattern "18:" to end of file "$".
p --> Print

awk '/18:/{ flag=1; } 
               { 
                     if (flag) { print }  
               }' "file"
awk '/18:/,0' inputfile

Fisrt find the line above which should be deleted, then use sed to delete all
the desired lines.
As follow,(newer in unix,pls try:p)
num=`awk '{
if($3=="18:01")
n=NR;
}
END{
print n;
}' filename`
num=`expr $num - 1`
sed "1,${num}d" filename