Re: Trouble with SED (121 Views)
Reply
Frequent Advisor
Chris Elmore
Posts: 51
Registered: ‎05-07-2002
Message 1 of 4 (121 Views)
Accepted Solution

Trouble with SED

getting unable to parse on the following sed stmt:

sed -n '${x},${y}p' $filnam

where x=beginning line number and
y=ending line number of text in a file I'm trying to extract. Been searching manuals but no solution yet.
"Life is love and love is life"
Please use plain text.
Honored Contributor
Patrick Wallek
Posts: 13,752
Registered: ‎06-21-2000
Message 2 of 4 (121 Views)

Re: Trouble with SED

Remove the single-quotes from your statement.

sed -n ${x},${y}p ${filnam}

Please use plain text.
Honored Contributor
Sundar_7
Posts: 1,938
Registered: ‎11-07-2000
Message 3 of 4 (121 Views)

Re: Trouble with SED

Chris,

It is because the single quotes around the expression will not let the shell to expand the values of $x and $y.

Use double quotes around the expression.

sed -n "${x},${y}p" $filnam

Sundar
Learn What to do ,How to do and more importantly When to do ?
Please use plain text.
Frequent Advisor
Chris Elmore
Posts: 51
Registered: ‎05-07-2002
Message 4 of 4 (121 Views)

Re: Trouble with SED

Thanks folks, that fixed the problem. Both your time and expertise was greatly appreciated.

Very Respectfully,
Chris Elmore
"Life is love and love is life"
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation