LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:25 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
Open Source Consulting | Domain Registration