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

chop in kornshell?

Reply to Message Icon

Original Message
Name: ShaqDiesel
Date: July 19, 2005 at 16:48:59 Pacific
Subject: chop in kornshell?
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.


Report Offensive Message For Removal

Response Number 1
Name: cislord
Date: July 24, 2005 at 16:37:35 Pacific
Subject: chop in kornshell?
Reply: (edit)

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.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: chop in kornshell?

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software