I have to rename multiple files in directory by removing first 5 characters for each filename.
How can I do this i bash/shell? I'm using Ubuntu 11.10. Thanks.
Tell me more
×
Server Fault is a question and answer site for
professional system and network administrators. It's 100% free, no registration required.
|
|
|
A simple for loop with a bit of
The substitute regex in |
|||
|
|
|
Bash has some amazing scripting possibilities. Here's one way:
A handy way to test what it would do is to add an echo in front of the command:
The six question marks ensure that you only attempt to do this to filenames longer than 5 characters. |
|||
|
|
|
You can use sed to do this
|
|||
|
|
|
All great answers, thanks. This is what worked in my case:
|
|||
|
|
