BASH - Rename multiple files using tr and sed
Hi All!
I'd like to rename several files but the script gets hung, any ideas Code:
#!/bin/bash ONE_FILE-_-_(2008)_balance.doc TWO_filR-_-_(2010)_balance.doc THREE_File-_-_(2004)_balance.doc FOUR_fiLe-_-_(2005)_balance.doc FIVE_fIle-_-_(2005)_balance.doc |
hmmm ... maybe you could show us what you start with and the desired end result, as obviously the current solution is not doing what you want?
Also as there is no mv command anywhere, I am a bit perplexed at how any renaming is to occur? |
SOrry, that was an old version
Code:
#!/bin/sh mv: missing file operand Try `mv --help' for more information. expected output of the files one_file_(2008)_balance.doc two_filr-_-_(2008)_balance.doc three_file-_-_(2004)_balance.doc ... ... ... |
Well firstly you should this about parsing ls and its dangers.
Then you will need to read this one on word splitting as you have not quoted your variables and have already shown with the code that the file names will have spaces in them. I presume you just want to play with tr and sed for practice? Because you would know that sed can handle all the changes required? |
finally i achived this
Code:
#!/bin/sh |
Well I see you ignored all the advice, so I will show you an alternative just in case:
Code:
#!/bin/bash |
thanks a bunch, i had not seen your previous post.
|
All times are GMT -5. The time now is 05:02 PM. |