LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   SED and shell variables (https://www.linuxquestions.org/questions/linux-software-2/sed-and-shell-variables-397421/)

3saul 12-28-2005 10:07 PM

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

Matir 12-28-2005 11:17 PM

Yeah, use double quotes (").

3saul 12-28-2005 11:23 PM

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

Matir 12-28-2005 11:29 PM

oops. :)
Code:

sed "${Variable}q;d" files.txt

3saul 12-28-2005 11:37 PM

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).


All times are GMT -5. The time now is 07:12 PM.