Computing.Net > Forums > Unix > set variable to and exec sequence

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

set variable to and exec sequence

Reply to Message Icon

Name: tqnguyen67
Date: May 26, 2004 at 12:19:15 Pacific
OS: unix
CPU/Ram: 400Mhz
Comment:

Hi all;

I keep getting syntax error on this command. Would any one help?

set [ $var [ exec grep "testtime" testfile.log | sed -e "/repo/s/.*.repo//" | sed -e "/ -f/s/ -f.*.//" | sed -e "/ -DMPMD/s/ -DMPMD.*.//" | sed -e "/ -a/s/ -a.*.//" | sed -e "/ -continue/s/ -continue.*.*//" | cut -d "/" -f 2 | uniq ]]

I set the result of the exec to $var
the exec sequence is a grep for a parttern and strip everything off.

Thanks all



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: May 27, 2004 at 04:50:41 Pacific
Reply:

This looks like expect.

set [ $var [ exec grep "testtime" testfile.log | sed -e "/repo/s/.*.repo//" \
-e "/ -f/s/ -f.*.//" \
-e "/ -DMPMD/s/ -DMPMD.*.//" \
-e "/ -a/s/ -a.*.//" \
-e "/ -continue/s/ -continue.*.*//" | cut -d "/" -f 2 | uniq ]]

Instead of piping the results to another instance of sed, you can string multiple condtions together with the "-e" flag.

Consider using a different delimter other than "/" if your pattern will contain slashes.

sed -e "/repo/s/.*.repo//"
could look like either

sed -e ",repo/s/.*.repo,,"
or
sed -e "/repo\/s\/.*.repo//"



0

Response Number 2
Name: tqnguyen67
Date: May 27, 2004 at 10:17:39 Pacific
Reply:

yes, it is expect
the exec grep work fine
the problem is set not the sed


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: set variable to and exec sequence

Pass environment variables to sed www.computing.net/answers/unix/pass-environment-variables-to-sed/7387.html

set variables from date conversion www.computing.net/answers/unix/set-variables-from-date-conversion/6682.html

Problem setting variable...help! www.computing.net/answers/unix/problem-setting-variablehelp/6467.html