I wish to replace my failing memory with a very small shell script.
#!/bin/sh if ! [ –a $1.sav ]; then mv $1 $1.sav cp $1.sav $1 fi nano $1
is intended to save the original version of a script. If the original has been preserved before, it skips the move-and-copy-back (and I use move-and-copy-back to preserve the original timestamp).
This works as intended if, after I make it executable with chmod I launch it from within the directory where I am editing, e.g. with
However, when I move it into /usr/bin (so it is in the path as verified with echo $PATH) and then I try to run it in a different directory (without the leading ./ ) it fails with
-bash: /usr/bin/safe.sh: /bin/sh: bad interpreter: Text file busy
D'oh? Inquiring minds want to know how to make this work.