Running this in terminal runs fine:
for a in *.pdf; do mv "$a" "$a".tmp; done
Running this inside a bash script (#!/bin/bash
)
for a in "$1"; do mv "$a" "$a".tmp; done
...and passing the parameter *.pdf
, i.e. ./myscript *.pdf
, the script processes only the first file in the directory. Testing by changing mv
to echo
shows the same thing.
Any explanation why this is so, and how I could make it work to process all file matches? Thanks!