Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-05-2009, 06:00 AM   #1
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.
sed '5c\ disk = jskdjfdsk' vm.cfg
How do i substitute a variable in place of 5
for example
i tried substituting
sed '$variablec\ disk = jskdjfdsk' vm.cfg
sed '"$variable"c\ disk = jskdjfdsk' vm.cfg
but they didnt worked .
Please help
Old 11-05-2009, 06:38 AM   #2
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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
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.


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 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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:50 AM.

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