Click to See Complete Forum and Search --> : I suck at shell scripting!!!


labwerx
02-03-2006, 07:29 PM
I really need help with this stupid script. I'm horrible at shell scripting, downright horrible I tell you!

here's what I need to do:

- take the output of a command, or string of commands, for example:

rpm -q tcptrace

- and stick it's output into a variable. I can work my logic magic from there. Technically, if I were to echo $variable it would show

tcptrace-6.6.7-1.2.el4.rf

This should probably be something so simple that a braindead gerbil could probably do it, but I can't figure it out.

hlrguy
02-03-2006, 07:50 PM
the backticks (under ~ and NOT single quotes) tells bash to send the command to the shell. The cow= part says stick whatever the output is into the variable cow.

CODE

#!/bin/bash
cow=`rpm -q tcptrace`
echo $cow

/code

These should help.
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://linuxreviews.org/beginner/Bash-Scripting-Introduction-HOWTO/

hlrguy

P.S. We all sucked until when we started. :p