6

I need to create 26 files named a to z in single command. I thought touch command would be sufficient with the regex, but it doesn't expand [a-z] instead it creates a single file with name "[a-z]".

$ touch [a-z] 

Any way to achieve these?

Note:

$ bash -version GNU bash, version 4.3.30(1)-release (i686-pc-linux-gnu) 
0

1 Answer 1

13

In bash (version 3.0 (2004) and above), ksh (since ksh93r (2006)) and zsh (version 5.0.6 (2014) and above):

touch {a..z} 

(note that only zsh supports characters other than ASCII letters and digits, none goes as far as perl's .. operator which inspired those shells operators).

With other zsh version (since 2.2 (1992)):

setopt braceccl touch {a-z} 
8
  • Just tested it and that works great on Ubuntu. Commented Aug 20, 2015 at 17:13
  • bash and zsh and some other shells will expand {a..z} to an ASCII sequence of 26 separate arguments. Your /bin/sh however might not know about it. Commented Aug 20, 2015 at 17:16
  • Thanks for your response. still no success, I am bash 4.3 Commented Aug 20, 2015 at 17:20
  • cool. it works like a charm. I was giving wrong command. it is .. and not hyphen.. Thanks Commented Aug 20, 2015 at 17:20
  • @SaulOrtega: Yes, of course, that's why I mention only bash, ksh and zsh. Commented Aug 20, 2015 at 17:21

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.