Another bash for loop time saver

People are sometimes amazed at how quickly I get some things done. Truth be told I’m lazy and hate having to do more than I need to. Sometimes it is great to have just enough programming background to be dangerous.

I’ve posted about for loops before and they are probably one of my most liked bash items. Here is another reason why.

I’m working on a web site and I need to edit a bunch of files, they all need the same edits done and there is no reason I should get interrupted from working on them all in series. Enter the for loop! With the following command I can edit each file in VIM and when I close the file the next file will open for me.

for I in `ls *.php`
do
vim $I
done

Nice and simple.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.