You are not logged in.
below is script i am trying. I am trying to get the latest modified file in a folder:
#!/bin/bash
shopt -s extglob
name=$(echo *(om[1]))
echo $namei am expecting filename instead *(om[1]) is echoed. As such the script does not give any error due to using shopt.
i try the command on commandline it gives the filename as output.
% cd other
% echo *(om[1])
mumbai123.txtwhy echo *(om[1]) is working on commandline but not in bash script.
Last edited by sant527 (2014-10-02 03:53:53)
Offline
i changed the #!/bin/bash to #!/bin/zsh and also removed the shopt command. it works.
Offline
why echo *(om[1]) is working on commandline but not in bash script.
Are you using zsh as your shell?
Offline