Output of command used in the next command


Hello everyone. Am new here have a multi-step question.

I am writing a script to work in ubuntu 12.04 linux that has a bunch of steps. Not a avid scripter, and this is probably (hopefully) easy for everyone else to understand.

I am building an installer that will.
Run another script, and wait for that to finish. This I know how to do.
Then rename a pair of files to blah.war.old
Then run one of the new files through a shasum/sha1sum and use that output to make a directory where then the .war file will get
placed in that newly created folder.

aka $shasum blah.war
$ dfjdkjfkdjfkdjfkdjfkdjfdkjfdkj
mkdir /blah/blah/blah/dfjdkjfkdjfkdjfdjfjfdkjf
mv blah.war /blah/blah/blah/kjfdjfkdjfkdjfdkjfdk

Then there is the trick that that same output from teh shasum will be used to update a database system properties but one step at a time I guess.

So I guess the question is what do I use in the shell script bash to get that output from one command to the next, and maybe to another command down the chain?



for now try if this is what you are looking for:


out=`shasum $1 | cut -d " " -f1`
mkdir -p /tmp/path/to/my/dir/$out
mv $1 /tmp/path/to/my/dir/$out

here is how it works:

 $ echo LinuxCareer.com > myfile
 $ ./test.sh myfile
 $ cat /tmp/path/to/my/dir/381ad8ef95d8eeaf2b9c1c4bc17d91a064972807/myfile 

Let me know if this is what you need…


opened #3