Computing.Net > Forums > Unix > command output running

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.

command output running

Reply to Message Icon

Name: tvc
Date: November 8, 2009 at 06:11:07 Pacific
OS: unix
CPU/Ram: n/a
Product: Sony Crash bash (psx)
Subcategory: Software Problems
Comment:

Often found myself writing commands similar to this:

<whatever command> | awk -F"a=" ' { print $2 } ' | awk ' { print "a=" $1 } ' > temp.sh

This to create another shell script, which subsequently can get run, in this case to initiate variable "a" with a given value, which then further can be used inside the same script.

I know you can this for example:

thisuser=`id -un`

This would fill in a variable, with the result of the command. I've tried to do the similar, starting from the above (large) command, which would be something like this:

`<whatever command> | awk -F"a=" ' { print $2 } ' | awk ' { print "a=" $1 } '`

But, this does not always work. Question is, how do you do these kind of things, WITHOUT using a temporary file ? (so, WITHOUT redirection to a file)

Feel free to ask if you do not understand, it's a bit of a complex thing



Sponsored Link
Ads by Google

Response Number 1
Name: thepubba1
Date: November 16, 2009 at 02:17:10 Pacific
Reply:

If I have a file (in this example, we'll call it junk.file) with one field and that field has the value of ls, then all I have to do to run the ls command is type:

$(awk '{print $1}' junk.file)

So if I'm understanding your question properly, all you want to do is run the output of your awk command. If so, this should work from the Korn shell.


0
Reply to Message Icon

Related Posts

See More


file parsing Scripting Problem


Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: command output running

run unix command thr java program www.computing.net/answers/unix/run-unix-command-thr-java-program-/5887.html

Unix Find command output to file www.computing.net/answers/unix/unix-find-command-output-to-file/6677.html

Create an alias or command ? www.computing.net/answers/unix/create-an-alias-or-command-/7104.html