Here is how you would use a parameter to your script, which I will call Foo.sh
.
#!/bin/bash
pushd "$1"
... Do rest of stuff
popd
When you invoke the script, you would say :
./Foo.sh my/path/goes/here
If you wanted to pull the parameter out of a file, let's say called Bar.txt
, you could use head
with xargs
.
head -n 1 Bar.txt | xargs ./Foo.sh
Note that the line above assumes that the first line of Bar.txt
is exactly equal to the path.
If you had the form of varname=the/path
, you could grab the right part of the assignment using awk
.
head -n 1 Bar.txt | awk -F'=' '{print $2}' | xargs ./Foo.sh
Update: It appears that the OP is calling his own script in an infinite loop, if I am reading his code correctly. Since you seem to want to hardcode PARAM.txt
into your script, here is probably what you want.
cd `head -n 1 PARAM.TXT | awk -F'=' '{print $2}'`
for file in *.tar.gz;
do tmp=${file:34} && b=${tmp%.tar.gz*} && tar tfz "${file}" > "${b}.fl" && tar xzvf "${file}" && rm "${file}";
done