M HYPE SPLASH
// general

Create many files via touch command

By Andrew Adams

I want to create files like 00001 00002 ... $i (i need these files to start with 0) via touch command. I tried lots of things but it was unsuccessful.

NOTE: I've an environmental variable like i=`ls -1 | wc -l` and i wanna use it in my case.

I also tried these:

touch {01..$i}
touch {01..$(echo $i)}
touch {000001..00$i}
touch {000001..00$(($i))}
touch {000001..00$(($i+1-1))}
touch {000001..$(00$i)}
touch {000001..$((00$i))}
touch {000001..$(($i))}
touch {000001..$((00000+$i))}
touch {000001..$((00+$i))}
touch {000001..$((000+$i))}
touch {000001..$((0000+$i))}
touch {000001..$((echo 00$(($i)))}
touch {000001..$((echo "00$i"))}
touch {000001..$(($(echo "00$i")))}
touch {000001..$(echo -n "00$i")}
touch {000001..00echo -n $i}
touch {000001..00$((echo -n $i))}
touch {$i..000001}
touch {00$((i))..000001}
0

1 Answer

You can use seq to create the sequence of numbers and pipe its output into xargs to call touch for each number:

seq -w $i | xargs touch

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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