sag47
September 10th, 2008, 08:34 PM
Hello all,
I'm currently writing automated bash scripts for a linux box and wish to handle the output from the pipes...
To further explain what I'm trying to accomplish here is an example:
# cd ~
# ls -a | grep '^.m'
.macromedia/
.madedit/
.maltego/
.mcop/
.mcoprc/
.mozilla/
.msf3/
#
I want to handle each directory above as an input for another set of commands as it goes down the hierarchy of all the folders that start with ".m". This process needs to be automated since the amount and names of ".m" folders changes and increases as more are created.
So basically the solution I need is to echo text and folder into a file.
I'm basically want the automation to look like this:
# echo "#! /bin/bash" >> myfile.sh
# echo "sh .macromedia/configure.sh" >> myfile.sh
# echo "sh .madedit/configure.sh" >> myfile.sh
# echo "sh .maltego/configure.sh" >> myfile.sh
# echo "sh .mcop/configure.sh" >> myfile.sh
# echo "sh .mcoprc/configure.sh" >> myfile.sh
# echo "sh .mozilla/configure.sh" >> myfile.sh
# echo "sh .msf3/configure.sh" >> myfile.sh
That way I can call myfile.sh and have it run in sequence. Later I'll need it to run multiple commands on each of those directories but I want to keep it simple and take it one step at a time.
I've already tried stuff like
ls -a | grep '^.m' | echo "sh " >> myfile.sh
echo "sh `ls -a | grep '^.m'`/configure" >> myfile.sh
Is there an argument for each line output? Such as $1 where I can include it in the commands and make it look like (this also does not work btw but I'm looking for something similar)...
ls -a | grep '^.m' | echo "sh $1/configure.sh" >> myfile.sh
SAM
I'm currently writing automated bash scripts for a linux box and wish to handle the output from the pipes...
To further explain what I'm trying to accomplish here is an example:
# cd ~
# ls -a | grep '^.m'
.macromedia/
.madedit/
.maltego/
.mcop/
.mcoprc/
.mozilla/
.msf3/
#
I want to handle each directory above as an input for another set of commands as it goes down the hierarchy of all the folders that start with ".m". This process needs to be automated since the amount and names of ".m" folders changes and increases as more are created.
So basically the solution I need is to echo text and folder into a file.
I'm basically want the automation to look like this:
# echo "#! /bin/bash" >> myfile.sh
# echo "sh .macromedia/configure.sh" >> myfile.sh
# echo "sh .madedit/configure.sh" >> myfile.sh
# echo "sh .maltego/configure.sh" >> myfile.sh
# echo "sh .mcop/configure.sh" >> myfile.sh
# echo "sh .mcoprc/configure.sh" >> myfile.sh
# echo "sh .mozilla/configure.sh" >> myfile.sh
# echo "sh .msf3/configure.sh" >> myfile.sh
That way I can call myfile.sh and have it run in sequence. Later I'll need it to run multiple commands on each of those directories but I want to keep it simple and take it one step at a time.
I've already tried stuff like
ls -a | grep '^.m' | echo "sh " >> myfile.sh
echo "sh `ls -a | grep '^.m'`/configure" >> myfile.sh
Is there an argument for each line output? Such as $1 where I can include it in the commands and make it look like (this also does not work btw but I'm looking for something similar)...
ls -a | grep '^.m' | echo "sh $1/configure.sh" >> myfile.sh
SAM