« gumstix says bang womp womp womp! | Main | Geek wants his information! »

bash is cool

We know this functionality is there, but often forget.
IF we have a directory full of folders with plone_*

for i in plone_*; do mv $i iavtheme_${i#plone_}; done

will replace plone_ with iavtheme_ for each directory name

See these for other pattern toys (thanks Juan for reminding me of this useful stuff I never seem to use):

${variable%pattern}
Trim the shortest match from the end
${variable##pattern}
Trim the longest match from the beginning
${variable%%pattern}
Trim the shortest match from the end
${variable#pattern}
Trim the shortest match from the beginning

http://linuxgazette.net/issue18/bash.html

TrackBack

TrackBack URL for this entry:
http://www.jonathansaggau.com/blog/mt-tb.cgi/79

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)