![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Splitting the data and storing it into 2 variables | jisha | Shell Programming and Scripting | 10 | 02-17-2008 10:40 PM |
| Using variables in sed commands | hcclnoodles | Shell Programming and Scripting | 2 | 01-02-2007 08:56 AM |
| Referencing variables in commands | mharley | Shell Programming and Scripting | 3 | 03-31-2005 01:37 AM |
| awk - storing data in variables | 2nilotpal | Shell Programming and Scripting | 7 | 04-16-2004 05:32 AM |
| Subing Variables with commands. | Astudent | UNIX for Dummies Questions & Answers | 1 | 02-26-2001 05:02 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Storing commands in $variables.
Hi I'm trying to store commands in variables... like so..
# lastcmd=" $t1 | $t2 | $t3 | $t4 | sort | uniq" t1="sed -e 's/http:/<li><a href=\"http:/'" t2="sed -e 's/http:.*/&\">&<\/a>Web Link<br>/'" t3="sed -e 's/.*[0-9]. mailto:/<li><a href=\"mailto:/'" t4="sed -e 's/mailto:.*/&\">&<\/a>Email Link<br>/'" The code will work when not in the variables but its messy is there any way of storing these things like above ? echo $t1 etc Produces the desired string I'm wanting to run... Any suggestions ? sed: -e expression #1, char 1: unknown command: `'' is the error I get when I try to run the script.... The code that i'm running to test this part is t1="sed -e 's/http:/<li><a href=\"http:/'" t2="sed -e 's/http:.*/&\">&<\/a>Web Link<br>/'" t3="sed -e 's/.*[0-9]. mailto:/<li><a href=\"mailto:/'" t4="sed -e 's/mailto:.*/&\">&<\/a>Email Link<br>/'" lynx -dump "$1" | \ sed -e '1,/^References$/d' \ -e 's/.*[0-9]. //' | \ $t1|$t2|$t3|$t4 Thanks. Paul. |
|
||||
|
Thanks the eval worked... but it doesn't full work with the varible... tried with echo didn't seem to work. Just outputed it to the screen.
t1="sed -e 's/http:/<li><a href=\"http:/'" t2="sed -e 's/http:.*/&\">&<\/a>Web Link<br>/'" t3="sed -e 's/.*[0-9]. mailto:/<li><a href=\"mailto:/'" t4="sed -e 's/mailto:.*/&\">&<\/a>Email Link<br>/'" #lastcmd="eval $t1| eval $t2| eval $t3| eval $t4 | sort |uniq" lynx -dump "$1" | \ sed -e '1,/^References$/d' \ -e 's/.*[0-9]. //' | \ eval $t1| eval $t2| eval $t3| eval $t4 | sort |uniq That will work however I would like to replace the "eval $t1| eval $t2| eval $t3| eval $t4 | sort |uniq" with $last command.. THe #ed line above will not work when called like this... lynx -dump "$1" | \ sed -e '1,/^References$/d' \ -e 's/.*[0-9]. //' | \ eval $lastcmd or using $lastcmd with out the eval.... Any suggestions of how to put those all inside lastcmd ? Thanks. Last edited by Paulw0t; 03-13-2007 at 11:52 AM.. |
|
||||
|
lastcmd="sed -e 's/http:/<li><a href=\"http:/'| sed -e 's/http:.*/&\">&<\/a>Web Link<br>/'| sed -e 's/.*[0-9]. mailto:/<li><a href=\"mailto:/'| sed -e 's/mailto:.*/&\">&<\/a>Email Link<br>/' | sort | uniq"
This will do the job without using the t1/2 variables only i can't put it on new lines etc and makes for hard to read code :S |
|
||||
|
I am facing a similar problem in Perl.
my $command = "$scp $repository/$nameoffile user@$server:/dir/$name"; This line is not executing and I don't know how to capture this error from the shell in perl. Can anyone help me with this? It would be much appreciated. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|