LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 07: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, 07:38 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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, 02: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration