nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Little problem with sed

This is a discussion on Little problem with sed within the Shell scripting forums, part of the Development/Scripting category; Hello, I'm using sed to replace n occurrences. But when I wan to replace my 10th occurrence with the \10, ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 07-18-2005, 03:12 PM
Jordix
Guest
 
Posts: n/a
Default Little problem with sed

Hello,

I'm using sed to replace n occurrences.
But when I wan to replace my 10th occurrence with the \10, I get replaced with the first occurrence and the number 0.
Here is part of my command:

s:\([0-9];\)\([0-9];\)\([0-9];\)......\([0-9];\)\([0-9];\):\1,\2,\3......,\10,\11:g

I have tried '\10' etc.. but I don't find the exact expression.
Can you help me please?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-20-2005, 12:35 AM
Guest
 
Posts: n/a
Default

Replace \10 with \\10
Reply With Quote
  #3 (permalink)  
Old 08-10-2005, 02:28 AM
googlybear
Guest
 
Posts: n/a
Default help with sed commands

I am new to shell scripting, and i have many files that need editing. My problem is some lines end with a / and I need to find the next line after this and join the two together.

I have found the following one liners but i am unable to rearrange them to come up with what i need.

script 1:
# if a line ends with a backslash, append the next line to it
/bin/sed -e :a -e '/\\$/N; s/\\\n//; ta' < input.file> output.file

script 2:
# if a line begins with an equal sign, append it to the previous line
# and replace the "=" with a single space
#/bin/sed -e :a -e '$!N;s/\n=/ /;ta' -e 'P;D' < input.file> output.file

I would be grateful is someone could point me in the right direction, all the help files and faqs i have come across do not show all posiblities and / or what all the characters mean.

thanks
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +5.5. The time now is 03:24 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36