LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux 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
  Search this Thread
Old 11-05-2009, 06:00 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 37
Help needed for sed command.


I want to execute below command using line number as a variable.
Code:
sed '5c\ disk = jskdjfdsk' vm.cfg
How do i substitute a variable in place of 5
for example
i tried substituting
Code:
sed '$variablec\ disk = jskdjfdsk' vm.cfg
and 
sed '"$variable"c\ disk = jskdjfdsk' vm.cfg
but they didnt worked .
Please help
 
Old 11-05-2009, 06:38 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Code:
sed "$variable c\ disk = jskdjfdsk" vm.cfg
The space after "variable" is required---so that it does not try to evaluate the value of "variablec"
 
Old 11-06-2009, 01:57 AM   #3
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
do not put variables in single quotes, the dollar looses its special meaning in it, use the double quotes, and as pixellany said use the space after the variable.
 
  


Reply



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
sed help needed ZAMO Linux - General 7 01-09-2009 06:58 AM
sed help needed avijitp Programming 8 11-19-2007 08:33 AM
awk or sed help needed cmontr Programming 42 11-02-2007 11:43 PM
SED help needed DriveMeCrazy Linux - General 2 11-20-2006 10:04 PM
Sed/Awk command help needed. farmerjoe Programming 3 03-02-2005 11:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:00 AM.

Main Menu
Advertisement
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
Twitter: @linuxquestions
Open Source Consulting | Domain Registration