skmdu
July 7, 2009, 4:59am
1
Hi,
I have file which has the following content...
GOOD MORNING
**********WARNING**********
when it kicks from the kickstart, sshd daemon should start at last.
(WHEN KICKING ITSELF, NOT AFTER KICKING).
/etc/rc3.d/S55sshd ( run level specification for sshd is 55, now I would want to change this to S99sshd.
**********WARNING***********
THANKYOU
I want to write sed command to remove the data which is there in between *****WARNING****.
My expected output is:
GOODMORNING
THANKYOU
Kindly help me to do this...
Even if its in awk that is also appreciated.
This may be simple and will work if you have only two "WARNING" keywords in the file
#!/usr/bin/sh
start=`grep -n WARNING file1 | cut -d":" -f1 |head -1`
end=`grep -n WARNING file1 | cut -d":" -f1 |tail -1`
sed "$start,$end d" file1
sed '/WARNING/,/WARNING/d'
or perl:
$_=<<EOF;
GOOD MORNING
**********WARNING**********
when it kicks from the kickstart, sshd daemon should start at last.
(WHEN KICKING ITSELF, NOT AFTER KICKING).
/etc/rc3.d/S55sshd ( run level specification for sshd is 55, now I would want to change this to S99sshd.
**********WARNING***********
THANKYOU
EOF
s/\*+WARNING\*+.*\*+WARNING\*+\n//s;
print;
skmdu:
Hi,
I have file which has the following content...
GOOD MORNING
**********WARNING**********
when it kicks from the kickstart, sshd daemon should start at last.
(WHEN KICKING ITSELF, NOT AFTER KICKING).
/etc/rc3.d/S55sshd ( run level specification for sshd is 55, now I would want to change this to S99sshd.
**********WARNING***********
THANKYOU
I want to write sed command to remove the data which is there in between *****WARNING****.
My expected output is:
GOODMORNING
THANKYOU
Kindly help me to do this...
Even if its in awk that is also appreciated.
I laid my hands on this command..I hope it helps:
user@server > sed '/^*/,/^*/d' temp.txt
GOODMORNING
THANKYOU
where temp.txt is your text above.
skmdu
July 7, 2009, 8:11am
5
Hi everybody,
Thank you so much for your valuable reply...
Finally I used,
sed '
:loop
s|\**WARNING\**\(.*\)\**WARNING\**||
t loop
/WARNING/!b
N
b loop' filename
Thank you once again.