You are not logged in.
Pages: 1
I have a bunch of files (archives actually) that each need directories of the same name. There are approximately 400 of these will rather long names, so I have no desire to type them all out. My plan was to output a list of the files from ls, trim the file extensions from the list, and then pipe that list into mkdir. Voila right? Except I can't figure out how to get mkdir to read from the list. I've tried various ways I could think of like cat dirlist | mkdir, mkdir | cat dirlist, etc, but none work.
I know I can't be the first to want to make a list of directories from a list so there must be a way. Heck I used to do it in Windows and we all know how weak that command line is ![]()
Thanks
Plex
Last edited by Plexxxy (2007-02-09 19:19:36)
Offline
There are probably many ways to achieve what you want. Here's one of them (which requires xargs):
cat dirlist | xargs -L 1 mkdirOffline
Offline
cat dirlist | xargs -L 1 mkdir
Did not work on my machine.
Where get xargs?
Prediction...This year will be a very odd year!
Hard work does not kill people but why risk it: Charlie Mccarthy
A man is not complete until he is married..then..he is finished.
When ALL is lost, what can be found? Even bytes get lonely for a little bit! X-ray confirms Iam spineless!
Offline
% pacman -Qo `which xargs`
/usr/bin/xargs is owned by findutils 4.2.29-1
Offline
Another possibility if you're in ksh or bash is
for i in `cat dirlist`; do
mkdir $i
done
Of course, run that from the directory you want all the new ones to be created in.
Offline
Am I missing something? What's wrong with:
mkdir $(cat dirlist)Offline
[root@n6re ~]# mkdir $(cat dirlist)
cat: dirlist: No such file or directory
mkdir: missing operand
Try `mkdir --help' for more information.
[root@n6re ~]#
Prediction...This year will be a very odd year!
Hard work does not kill people but why risk it: Charlie Mccarthy
A man is not complete until he is married..then..he is finished.
When ALL is lost, what can be found? Even bytes get lonely for a little bit! X-ray confirms Iam spineless!
Offline
Another possibility if you're in ksh or bash is
for i in `cat dirlist`; do
mkdir $i
doneOf course, run that from the directory you want all the new ones to be created in.
one line:
for d in $(cat dirlist); do mkdir $d; doneOffline
[root@n6re ~]# mkdir $(cat dirlist)
cat: dirlist: No such file or directory
mkdir: missing operand
Try `mkdir --help' for more information.
[root@n6re ~]#
You need a file 'dirlist' with all the directories in it. ![]()
Offline
Pages: 1