LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 12-28-2005, 10:07 PM   #1
3saul
Member
 
Registered: Aug 2004
Location: Brisbane, Australia
Distribution: Ubuntu/Fedora
Posts: 86

Rep: Reputation: 15
SED and shell variables


Do you know how I can allow the shell to recognize the variable in this:

sed '$Variableq;d' files.txt

..where $Variable contains the line number to display
 
Old 12-28-2005, 11:17 PM   #2
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
Yeah, use double quotes (").
 
Old 12-28-2005, 11:23 PM   #3
3saul
Member
 
Registered: Aug 2004
Location: Brisbane, Australia
Distribution: Ubuntu/Fedora
Posts: 86

Original Poster
Rep: Reputation: 15
I've tried this but it doesn't work because its looking for a variable named $Variableq instead of $Variable

sed "$Variableq;d" files.txt
 
Old 12-28-2005, 11:29 PM   #4
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 118Reputation: 118
oops.
Code:
sed "${Variable}q;d" files.txt
 
Old 12-28-2005, 11:37 PM   #5
3saul
Member
 
Registered: Aug 2004
Location: Brisbane, Australia
Distribution: Ubuntu/Fedora
Posts: 86

Original Poster
Rep: Reputation: 15
Copied and pasted from your post but still not working. I get this error from SED..

sed: -e expression #1, char 1: unknown command: `''

I'm using GEdit and all other variables snow up as grey but the variable in this SED expression is pink (text/unknown).
 
  


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 with bash variables MurrayL Linux - Software 2 03-21-2005 08:13 AM
shell command help, sed i think infamous41md Programming 2 08-15-2004 02:55 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM
using bash variables in sed jimieee Programming 6 02-04-2004 04:11 AM
passing variables to sed jjfate Programming 8 07-31-2003 04:15 AM


All times are GMT -5. The time now is 06:58 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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration