Just use bash, no need to call external commands.
for file in *_h.png
do
mv "$file" "${file/_h.png/_half.png}"
done
Do not add #!/bin/sh
For those that need that one-liner:
for file in *.png; do mv "$file" "${file/_h.png/_half.png}"; done
More Related Contents:
- In the shell, what does ” 2>&1 ” mean?
- Difference between single and double quotes in Bash
- Command not found error in Bash variable assignment
- How to check if a variable is set in Bash
- Shell equality operators (=, ==, -eq)
- redirect COPY of stdout to log file from within bash script itself
- I just assigned a variable, but echo $variable shows something else
- Shell script to delete directories older than n days
- Shell: How to call one shell script from another shell script?
- Quick-and-dirty way to ensure only one instance of a shell script is running at a time
- Process all arguments except the first one (in a bash script)
- How to represent multiple conditions in a shell if statement?
- Generating permutations using bash
- Should aliases go in .bashrc or .bash_profile? [duplicate]
- How to read user input into a variable in Bash?
- What is the difference between ${var}, “$var”, and “${var}” in the Bash shell?
- What does the Bash operator
- Remove duplicate entries in a Bash script [duplicate]
- source command not found in sh shell
- How to parse a CSV in a Bash script?
- How to check if a file contains a specific string using Bash
- What’s a concise way to check that environment variables are set in a Unix shell script?
- Source files in a bash script
- executing shell command in background from script [duplicate]
- Waiting for background processes to finish before exiting script
- Variables as commands in Bash scripts
- How to split a file into equal parts, without breaking individual lines? [duplicate]
- How to wait for an open port with netcat?
- run bash command in new shell and stay in new shell after this command executes
- Subtract two variables in Bash