Computing.Net > Forums > Unix > sed:remove a trailing string

sed:remove a trailing string

Reply to Message Icon

Original Message
Name: Tintu
Date: February 5, 2007 at 23:29:11 Pacific
Subject: sed:remove a trailing string
OS: UNIX
CPU/Ram: 2.3 GHz
Model/Manufacturer: IBM
Comment:

Hi,
I have to remove a string from a file.
The content of the file looks like:

var1='123' or id like '111' or id like '222' or id like '345' or id like

I have to remove the last occuring 'or id like' from the file and the output file should be :

var1='123' or id like '111' or id like '222' or id like '345'

I tried the command :

sed 's/[ or id like ]*$//' file1 > file2

It is working fine if the input file is having upto 477 bytes. But if tried with more than 500 bytes nothing is writting to the output.

Could anybody help me.
Is this the right method? If so why it is not working if file size is big?

Or could you suggest any other method?



Report Offensive Message For Removal

Response Number 1
Name: thepubba1
Date: February 6, 2007 at 07:55:34 Pacific
Subject: sed:remove a trailing string
Reply: (edit)

A 20 entry on one line input file works fine and it is 731 bytes in length. I tried it in bash, ksh, and sh to eliminate shell differences.

What OS are you using (probably Solaris, which is where I see most of this weird behavior), what shell and what version of the shell.


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: sed:remove a trailing string

Comments:

 


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