Skip to main content
added 96 characters in body
Source Link
clarie
  • 95
  • 1
  • 4
  • 12

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

KindlyOutput enter image description here Kindly help!

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

Kindly help!

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

Output enter image description here Kindly help!

added 77 characters in body
Source Link
clarie
  • 95
  • 1
  • 4
  • 12

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

Kindly help!

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.

Kindly help!

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

Kindly help!

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$FILES variable is there with the output.

"$FILES"$FILES is passed as a input to the second function(command_to_get_filesizes) command_to_get_filesizes

But am getting errrerror as a Broken PipeBroken Pipe.

Can anyone pls help me to pass a local varibale from one function to another.

Kindly help!

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 errr as a Broken Pipe.

Can anyone pls help me to pass a local varibale from one function to another.

Kindly help!

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.

Kindly help!

edited tags
Link
clarie
  • 95
  • 1
  • 4
  • 12
Loading
Source Link
clarie
  • 95
  • 1
  • 4
  • 12
Loading