bash - saving output to a file in linux -
script:
#!/bin/bash mydir="/bamboo/artifacts" cd "$mydir" job="-job1" dir in */ bambooplan=`echo $dir | sed 's/\/$//g'`$job echo $bambooplan done
output:
lerst-tstredapidb2win4-job1 lerst-tstredapidb2win5-job1 ca-tstallsqlwin3-job1 ce-csw-job1 ce-snap-job1
i want pass file. tried commands below , gives permission denied error. me figure miss here?
echo $bambooplan > result.txt $bambooplan > result.txt
i tested code first 'writing line' (echo $bambooplan > result.txt
) , worked perfect me, change echo $bambooplan > result.txt
echo $bambooplan >> result.txt
, otherwise, overwrite entire file in each iteration, keeping last one.
be aware code writes inside /bamboo/artifacts
, wrote file path /bamboo/artifacts
, absolute path, not relative 1 -> bamboo/artifacts
, so, maybe, you're trying write in folder don't have writing permissions , need chmod
them.
Comments
Post a Comment