help with bash script: remove * to the last . in string
Hello, I finally decided to sit down and learn how to write scripts in bash so I wrote one to encode any video files in a directory to DIVx using mencoder. I wanted it to only touch valid video files by checking the suffix at the end of the file. I used FILESUF=${file#*.} to remove everything but the suffix. I ran into a problem with files that have multiple '.'s in the name. Is there a way to start at the end of the sting going backwards and remove everything after (and including) the first '.' it finds? THanks for the help!
Here is the full code for anyone that's interested: Code:
#!/bin/bash thanks! ...drkstr |
To remove everything until the last period, you'll need the ## ...
Code:
${file##*.} |
that was a lot more simple then I thought, thanks for the help! While I'm at it, is there a better way to check if something exists in an array instead of looping though and checking each element? Any thoughts on this would be much appreciated.
thanks! ...drkstr |
Quote:
|
All times are GMT -5. The time now is 06:16 PM. |