I am trying to chmod -R 644 /tmp/work/*
in bash script, however I get following error:
#!/usr/bin/env bash
shopt -s extglob
set -eu
mkdir -p /tmp/work/
chmod -R 777 /tmp/work/
sftp -o StrictHostKeyChecking=accept-new user1@hostname1:/tmp/test* /tmp/work/
chmod -R 644 /tmp/work/*
chmod: cannot access '/tmp/work/*': No such file or directory
While I try to run the same command in shell with the same user, it runs successfully.
Seems like issue with shell is due to glob expansion? so I have set shopt -s extglob
right before the chmod
command in bash, but still getting the same error.
Any ideas what am I doing wrong?
test
inuser1@hostname1:test
a file or a directory? The glob is just fine, and doesn't require anextglob
at all ... I'm wondering whether the transfer actually worked ...nullglob
notextglob
, but then chmod will complain about getting no filessftp
command, what doesls /tmp/work
give you? Based on the error message, I'm expecting nothing at all