-4

In order to demonstrate the use of 'wildcard' characters, issue a command to create the following empty files in your current directory:

a1  a11  a123  a1234  a23  a22  a3 1  11  123

someone told me to do this for him with the touch command. I tried 'touch a[*] [1-123] but did not work. please give me any solution

2

You can't use a filename globbing pattern to generate filenames unless the pattern matches existing filenames.

Doing touch a*[123] (or whatever globbing pattern) in an empty directory would under normal circumstances just create the file a*[123].

Brace expansions, on the other hand, generate strings on the command line without looking for existing names in the filesystem.

So, depending on what you mean by "wildcards", this may or may not be done at all.


You may tell your friend that if it takes longer time to figure out how to arrange the correct brace expansions to create the filenames than actually typing them out on the command line, then it's better just to type the filenames out literally. Brace expansions are supposed to be a shortcut.

However, if the filenames had been a bit more uniform, such as

1 12 123 a1 a12 a123 a11 a22 a33

then you could have used

$ touch {,a}1{,2{,3}} a{11,22,33}
|improve this answer|||||
0

Yes, use it as following.

touch a{1,3,11,22,23,123,1234} {1,11,123}

if you had a regular sequences like 0, 10, 20, 30 it could be done easily with the command as follows.

touch a{0..30..10}
|improve this answer|||||
  • if i want to do that in current directory then it is not working – Masum Billah Sep 9 '17 at 5:24
  • there is nothing related to if you are in which path except if you have had those names in current working directory – αғsнιη Sep 9 '17 at 5:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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