This is what I have:
#!/bin/bash
#ascript.sh
WORD1=`tail -n +$1 /home/gscn/word1.txt | head -1`
sed -e "s/WORD1/$WORD1/g" < /home/gscn/configtmp > /home/gscn/config
WORD2=`tail -n +$1 /home/gscn/word2.txt | head -1`
sed -e "s/WORD2/$WORD2/g" < /home/gscn/config2tmp > /home/gscn/config2
tscript.sh
When I do:
$ ./ascript.sh 1
It'll take the first word of both word1.txt and word2.txt files and put them in their respective config files. How do I make them separate? Like I want it so that I can do:
$ ./ascript.sh 1 5
Which will take the first word of the first word1.txt and put it in the respective config file, then take the fifth word of word2.txt and put it in the respective other config file. How can I achieve this?
The first parameter passed to the script it $1. The second is $2, etc. Is that what you are asking?
Mike
Okay, I tried this:
#!/bin/bash
#ascript.sh
WORD1=$1
WORD2=$2
echo "arg1 -> $arg1"
echo "arg2 -> $arg2"
WORD1=`tail -n +$1 /home/gscn/word1.txt | head -1`
sed -e "s/WORD1/$WORD1/g" < /home/gscn/configtmp > /home/gscn/config
WORD2=`tail -n +$1 /home/gscn/word2.txt | head -1`
sed -e "s/WORD2/$WORD2/g" < /home/gscn/config2tmp > /home/gscn/config2
tscript.sh
But when I do './ascript 1 5' it still uses the 1st word of both .txt files for each respective config instead of the 5th one for the second config
Is this what you are trying to do?
WORD1=`tail -n +$1 /home/gscn/word1.txt | head -1`
sed -e "s/WORD1/$WORD1/g" < /home/gscn/configtmp > /home/gscn/config
WORD2=`tail -n +$2 /home/gscn/word2.txt | head -1`
sed -e "s/WORD2/$WORD2/g" < /home/gscn/config2tmp > /home/gscn/config2
Mike
nvm I got it...I forgot $1 was already being used so I just changed the WORD2's argument to $2