Computing.Net > Forums > Unix > chop in kornshell?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

chop in kornshell?

Reply to Message Icon

Name: ShaqDiesel
Date: July 19, 2005 at 16:48:59 Pacific
OS: windows
CPU/Ram: amd; 384
Comment:

I have the following string filename(only has one double quote at end):
'arto.py"' I want sed to do a search and replace something with "Results/arto.py". I tried the following but it complained because of the last quotation mark.
sed -e "s/^filename=.*/filename=\"Results/$filename/g" $I > temp ($I is the current file in a loop)
Does kornshell have a chop command like PERL? I could solve this problem by chopping off that trailing " so sed doesnt complain and just hardcode both quotes as part of the replacement string
Any ideas? Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: cislord
Date: July 24, 2005 at 16:37:35 Pacific
Reply:

sed -e 's/.$//g' <filename> should delete the last character of each line in the file.

Alternatively
echo "some string" | sed -e 's/.$//g'
but be sure to escape special characters in the string.


0
Reply to Message Icon

Related Posts

See More


Database Platform? HELP! eliminate trailing



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: chop in kornshell?

skipping steps on a KornShell script www.computing.net/answers/unix/skipping-steps-on-a-kornshell-script/3504.html

korn shell help please www.computing.net/answers/unix/korn-shell-help-please/4364.html

Simple addition question www.computing.net/answers/unix/simple-addition-question/3179.html