Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how abt writing a script tht will do a 'ls' and then for each entry in the ls ... execute mkdir /home/dominant/new_dir
also split the listing on / and get the 'dominant' to chown the new dir
am not sure ... am also a newbie to linux but this is how i would try
hope it helps
what if you wanted to delete all wma files from the sub-sub and possibly sub-sub-sub directories? i tried "rm -r *.wma" from the parent directory and it says "rm: cannot remove *.wma: no such file or directory". there are wma file there though. i did an updatedb and then locate *.wma and many files come up.
for wma in `find /music -iname "*.wma"`; do rm -i $wma ; done
should do it. Replace /music with the base directory where your sub and sub-sub directories are. I've made it interactive (i.e. it will ask you before it deletes a file). If you're ABSOLUTELY sure you just want rid of them all then remove the -i bit from the rm command.
I am NOT responsible if you delete something you didn't mean to though!
It's a little late, but you can actually do it with a single command without the need for a script:
Code:
mkdir -p /home/dominant{,1,2,3,4}/new_dir
The shell expands that command by repeating the text surrounding the {}, but replacing what's inside the {} with each comma-separated value. Just as an example, it would expand to a single command like this:
Point taken, but you can use wildcards to a limited extent with the {}. You can use wildcards just so long as the they aren't adjacent to the opening curly brace.
While it doesn't use wildcards, you could handle the 50-60 dirs with a command like this:
You would end up with a /home/dominant0 through /home/dominant59.
Anyway... different tools are better suited for different situations. I don't usually see people use the {} expansion, and since it easily applied to the original post, I thought I would mention it.
Last edited by Dark_Helmet; 07-23-2004 at 05:37 PM.
Originally posted by dominant Thanks, it worked great!
No problem.
That's actually about the limit of my bash scripting (though I can do more in Perl) but it's amazing how useful it is to know even that much when you have a lot of files to change in some way.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.