You could use bash’s parameter expansion feature
for i in ./*.pkg ; do mv "$i" "${i/-[0-9.]*.pkg/.pkg}" ; done
Quotes are needed for filenames with spaces.
More Related Contents:
- Using sed to mass rename files
- How to Batch Rename Files in a macOS Terminal?
- Renaming files with Bash, removing prefix and suffix
- In the shell, what does ” 2>&1 ” mean?
- Command not found error in Bash variable assignment
- How to check if a variable is set in Bash
- What is the difference between $(command) and `command` in shell programming?
- Can I export a variable to the environment from a Bash script without sourcing it?
- How to urlencode data for curl command?
- Shell equality operators (=, ==, -eq)
- Assigning default values to shell variables with a single command in bash
- 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
- How to check the exit status using an ‘if’ statement
- Longest line in a file
- Simple method to shuffle the elements of an array in BASH shell?
- Piping and Redirection
- How to write a bash script to set global environment variable?
- What does “plus colon” (“+:”) mean in shell script expressions?
- How does AND and OR operators work in Bash?
- Running shell command that has nested quotes via ssh
- How to reload .bash_profile from the command line
- Floating point comparison in shell
- How to pipe stdout while keeping it on screen ? (and not to a output file)
- Escaping forward slashes in sed command [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
- Temporarily change current working directory in bash to run a command [duplicate]
- How to break out of a loop in Bash?