Iam new to linux and trying to pass a variable from one function to another in a same bash script.
Below is my code:
#!/bin/bash -x
FILES=$(mktemp)
FILESIZE=$(mktemp)
command_to_get_files(){
aws s3 ls "s3://path1/path2/"| awk '{print $2}' >>"$FILES"
}
command_to_get_filesizes(){
for file in `cat $FILES`
do
if [ -n "$file" ]
then
# echo $file
s3cmd du -r s3://path1/path2/$file | awk '{print $1}'>>"$FILESIZE"
fi
done
}
files=( $(command_to_get_files) )
filesizes=( $(command_to_get_filesizes) )
So in the above code, in the first function $FILES variable is there with the output.
$FILES is passed as a input to the second function command_to_get_filesizes
But am getting error as a Broken Pipe.
Can anyone pls help me to pass a local varibale from one function to another.
Output of $FILES is
2016_01
2016_02
2016_03
2016_04
