Reputation: 195
I'm using the 'at' command in order to create 3 directories, just a dumb bash script:
#!/bin/bash
for i in {1..3}
do
mkdir dir$i
done
Everything is ok if I execute that script directly on terminal, but when I use 'at' command as follows:
at -f g.sh 18:06
It only creates one directory named dir{1..3}
, taking interval not as an interval but as a list with one element {1..3}
. According to this I think my mistake is using bash script due to at
executes commands using /bin/sh but I'm not sure.
Please tell me if I'm right and I would appreciate some alternative to my code since even it is useless I'm curious to know what's wrong with at and bash.
Upvotes: 2
Views: 228
Reputation: 780818
The #!
line only affects what happens when you run a script as a program (e.g. using it as a command in the shell). When you use at
, it's not being run as a program, it's simply used as the standard input to /bin/sh
, so the shebang has no effect.
You could do:
echo './g.sh' | at 18:06
Upvotes: 2