facing issue in bitbucket pipeline script when using for loops

tanmay patil December 16, 2019

Hi All ,

This simple script runs fine in bash script ,

however in bitbucket pipeline it fails 

 - for folders in `ls -l | grep '^d' | awk '{print $9}'`  
-
do
-
if [ -d $folders ];then
-
echo $folders
-
cd $folders
-
sed -i.bak 's/markdown-header-//g' README.md
-
cd ..
-
fi
-
done

Error is bash: /opt/atlassian/pipelines/agent/tmp/bashScript8148302414251698626.sh: line 69: syntax error near unexpected token `printf'

Any help

1 answer

0 votes
tomas_Maggio August 20, 2020

The pipeline itself is YAML, so you'll need to do it like this:

- >
  for dir in $(ls -l | grep '^d' | awk '{print $9}'); do
    echo $dir
echo "do something else" done

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events