sed

Associate
Joined
1 Aug 2003
Posts
1,053
I am trying to use the sed command but my version seems to be different to the one described in books or online.

I am using debian and want to add some text to the begining of each line of a text file. Both i and a switches add new lines rather than editing current ones and my version doesn't seem to understand the s switch...

Any advice?
 
Version is 4.1.2

I have used various versions to try and get something working, due to being a little frustrated I began just random rubbish towards the end (at least it looks like that now but it seemed to make sense at the time).

The command sed i\ mogrify\ quality\ 75 will add lines but not add to a line.

The command sed -i s/^/texttoadd/ is not understood but change the '-i' to 'i\' and it will add s/^/texttoadd to a new line NOT append current lines
 
Ah, thank God someone said that rather than 'You massive tard!' - I was worried...

My sed is 4.1.2 - I could try updating sed and see where that gets me.
 
Grrr... now apt-get is playing up!

My sources seem to be invalid - I've got to go and hunt for some new ones, any suggestions or will I have to rely on Mr. Google, my special friend :)
 
Right.... sed seems to be behaving itself (have no idea why the version I was using was so out of date to the point of completely different command sets and rules).

Now I have the problem of Linux not understanding my commands - I think this is due to the obtusely complex file names that people decide to use.

With the command

mogrify -quality 75 /usr/data/PROJECTS/2933 Marshall St 2007/Images/D4325_0001.Foundation_(1024_x_768).jpg

It seems to get lost at the brackets, I have my ideas but would welcome suggestions...
 
Hmm, I think someone will call me a moron for not knowing how to do this but... how do I get sed to tack a ' at the end of every line.

To get round the special characters that people use, I'm putting the filenames in quotes
 
In trying to put quotes around the file names, I'm using two expressions, one to tack onto the front of the file name (which works) and one to tack on to the end... which I'm having problems with..

sed -i 's/$/\'/g'

It seems to get hung up on ', the \ is there as an escape character but doesn't work... any suggestions?
 
Back
Top Bottom