Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SED for regexp 1

Status
Not open for further replies.

christiniaroelin

Programmer
Sep 15, 2004
26
US
Hi,
i need to select only the lines that start with "echo" and within those lines delete anything after "=" including the "=" also.
for eg:

echo $ES_LD_END_HR='16'

should be

echo $ES_LD_END_HR

i have a sed statement as
sed '/^echo\(.*\)=\(.*\)/echo\2/g'< in.dat > out.dat

but gives an error as sed function not recognised.

Could anyone help provide insights on this please.

Thank You,
christinia.
 
Like this ?
sed -n '/^echo/s!=.*!!p' in.dat > out.dat

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,
Thanks for your help.
It works fine except for that it wrote lines only having an echo. i have in the datd file additional lines that doenot start with echo which need sto eb written to output also.

for eg:

input file

echo $ES_LD_END_HR='16'
some lines without echo
echo $xxx_HR='21'

expected output:
echo $ES_LD_END_HR
some lines without echo
echo $xxx_HR

Lines begining with echo needs to be stripped off after and including "=".

Could you please help me on this.

Thanks
Christi.



 
even simpler:
sed '/^echo/s!=.*!!' in.dat > out.da

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top