Watnog
asked on
SED: print lines from $DATE to end of file
HI EE,
I need help as I just can't make it work.
In a file I need all lines from 'date' written as 07/11/10 to end of file.
Date variable is written as:
DATE=`date '+%m/%d/%y'`
which outputs the correct format.
Normal notation for what I want would be:
sed -n '/regex/,Sp' in > out
Replacing the regex with $DATE:
sed -n '/$DATE/,Sp' in > out
won't work however, no matter how much I tried using single/double quotes, other seperators than /, working with \ as escape character, ....
I'm at a loss, 'date' is the only relevant criterium to select upon.
From attached file only lines starting from 07/11/10 till end of file should be retained.
Any alternative (for sed) that works is welcome too.
Platform is hpux with ksh.
Thanks for your help.
CL2-20100711-ABHO.txt
I need help as I just can't make it work.
In a file I need all lines from 'date' written as 07/11/10 to end of file.
Date variable is written as:
DATE=`date '+%m/%d/%y'`
which outputs the correct format.
Normal notation for what I want would be:
sed -n '/regex/,Sp' in > out
Replacing the regex with $DATE:
sed -n '/$DATE/,Sp' in > out
won't work however, no matter how much I tried using single/double quotes, other seperators than /, working with \ as escape character, ....
I'm at a loss, 'date' is the only relevant criterium to select upon.
From attached file only lines starting from 07/11/10 till end of file should be retained.
Any alternative (for sed) that works is welcome too.
Platform is hpux with ksh.
Thanks for your help.
CL2-20100711-ABHO.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much. DATE=`date +%m\\\/%d\\\/%y` is exellent.
ASKER
#!/bin/ksh
#
DATE=`date +%m\\/%d\\/%y`
echo $DATE
sed -n "/$DATE/,\$p" abho1.txt > abho2.txt
This is what is returned:
# ksh abho2.ksh
07/12/10
sed: /07/12/10/,$p is not a recognized function.
File used is attached.
abho1.txt