|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Name directories with "0s"
Hi everyone, I want to create 4000 directories with names like dir0001 ... dir 0100 till dir4000 and move 100 files in each. I am using this : Code:
ls|xargs -n100|awk ' {i++;system("mkdir dir"i);system("mv "$0" -t dir"i)}'I get the directory names at dir1, dir2 etc. which is not good for later sorting of directories. Thanks.
Last edited by vbe; 10-11-2012 at 08:36 AM.. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
try something like this.. Code:
for i in {1..1000}
do
dir_name=$(printf "%04d" "$i")
mkdir "$dir_name"
mv files "$dir_name"
doneLast edited by pamu; 10-11-2012 at 09:12 AM.. Reason: corrected after elixir's advise..:) |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Quote:
So, that's a useless use of awk . ![]() Last edited by elixir_sinari; 10-11-2012 at 09:11 AM.. |
|
#4
|
|||
|
|||
|
Quote:
edited in original post. ![]() This might be the first time useless use of awk ... ![]() |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thanks for all replies !!
|
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Quote:
Code:
printf "dir%04d" "$i" |
| Sponsored Links | ||
|
![]() |
| Tags |
| directory naming, dividing files |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| awk command to replace ";" with "|" and ""|" at diferent places in line of file | shis100 | Shell Programming and Scripting | 7 | 03-16-2011 08:59 AM |
| ps -ef | grep "string1" "string2" " "string3" | steve2216 | Shell Programming and Scripting | 11 | 09-03-2010 11:08 AM |
| "find command" to find the files in the current directories but not in the "subdir" | swamymns | Shell Programming and Scripting | 9 | 07-22-2008 11:23 AM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 12:52 AM |
|
|