I can't get touch to simultaneously create three empty files file1, file2, file3. I tried:
$ touch file[1-3]
but all I got was one file:
$ file[1-3]
What did I do wrong?
I can't get touch to simultaneously create three empty files file1, file2, file3. I tried:
$ touch file[1-3]
but all I got was one file:
$ file[1-3]
What did I do wrong?
With file[1-3], the current directory is searched and if filenames matching the pattern exist, the pattern is replaced with the list. Otherwise, the pattern is left alone.
If you:
touch file1 file2 file3 file4 file5
first, you command would update the timestamp on the first three.
What would you expect:
touch *
to do? Create all possible file names????
Now that would eat up some serious disk space
So there's no tricky way to use touch to create multiple files simultaneously in one brief command?
Use a loop,
i=1
while [ $i -le 5 ]; do touch file$i; i=`expr $i + 1`; done
Hi.
Some shells may help:
#!/bin/bash3 -
# @(#) s1 Demonstrate brace expansion.
echo
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1)
echo
rm -f scratch*
echo " Situation before:"
ls scratch*
touch scratch{1..3}
echo
echo " Situation after :"
ls scratch*
exit 0
Producing:
% ./s1
(Versions displayed with local utility "version")
Linux 2.6.11-x1
GNU bash 3.00.16(1)-release
Situation before:
ls: scratch*: No such file or directory
Situation after :
scratch1 scratch2 scratch3
See man page for details -- also worked on ksh 93s+ ... cheers, drl