LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Newbie
User Name
Password
Linux - Newbie This forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Thread Tools
Old 11-06-2009, 01:37 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 78
Thanked: 0
Help required for sed command.


[Log in to get rid of this advertisement]
I want a replacement of line at perticular line number
say Number = 5
and Variable = abc

whenever i execute the following command line 5 get replaced with $Variable but not abc.

What is wrong in below code
Code:
sed -e "$Number c\$Variable" vm.cfg > tmp

Last edited by pinga123; 11-06-2009 at 01:41 AM..
windows_xp_2003 pinga123 is offline     Reply With Quote
Old 11-06-2009, 01:45 AM   #2
indiajoe
Member
 
Registered: Jan 2009
Location: India
Distribution: Slax atma
Posts: 48
Thanked: 9
Put two slashes

Hi
You should put two slashes to prevent escape of $
Code:
sed -e "$Number c\\$Variable" vm.cfg > tmp
Cheers
-indiajoe
linux indiajoe is offline     Reply With Quote


Thanked by:

Reply

Bookmarks


Thread Tools

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help required with the tar command bsaheb Linux - Newbie 3 11-13-2009 09:47 AM
sed guru required for help with Win32 environment variables slugzero Programming 2 09-16-2009 02:04 AM
sed guru required for help with Win32 environment variables slugzero Slackware 11 09-12-2009 04:45 AM
SED;find and replace;help required gd13 Programming 3 12-21-2004 07:33 AM


All times are GMT -5. The time now is 11:31 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration