use bash for loop on prompt

you can run bash on prompt, not inside of Vi editor (reference)

Example)

$ for i in  {1..5}; do command-here;done

or

$ for((i=1;i=<10;i+=2));do echo “welcome $i times”;done

or

$ for i in /etc/*.conf; do cp $i /backup; done

 

Real Example)

you can create directories from 1985 to 2007 year.

$ for i in {1985..2006};do mkdir $i; done

 

 

So, Simple 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s