Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a database sqlite file called "a.db".

I need to copy it 25 times (once for each letter of the alphabet) to have: b.db, c.db, d.db... ... ... z.db.

How can I do this in the Bash shell?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

A for loop and brace expansion.

for pref in {b..z}
do
  cp a.db "$pref.db"
done
share|improve this answer
    
mmm .. it not work! I've simply copied and paste your code and run as bash shell... but it create a file: {a..z}.db –  stighy Sep 12 '11 at 11:57
    
I solved using : for pref in q w e r t y u i o p a s d f g h j k l z x c v b n –  stighy Sep 12 '11 at 12:04
    
Then you're not running bash, or you're running an ancient version. –  Ignacio Vazquez-Abrams Sep 12 '11 at 20:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.