RedHat Commands. OpenSolaris Commands. Linux Commands. SunOS Commands. FreeBSD Commands. Full Man Repository. Advanced Search. Contact Us. Forum Rules. Mark Forums Read. Thread Tools. View Public Profile for venhart. Find all posts by venhart. View Public Profile for saravanan.
Find all posts by saravanan. View Public Profile for priyam. Find all posts by priyam. View Public Profile for sydney In addition to the wildcard way, you can also use find at least GNU find to do this: find -mindepth 1 -maxdepth 1 -type d -print0 xargs -r0 rm -R As with other find lines, you can run the first part find -mindepth 1 -maxdepth 1 -type d to see a list of directories that will be removed.
A safer option here also assuming GNU mv is to do something like this: find -mindepth 1 -maxdepth 1 -type d -print0 xargs -r0 mv -i -t.. Thanks for the tip. I like the idea of moving to a separate directory before deleting. Evster not sure if Mac OS X find supports those. I'd guess fink is that still around? Or you could omit them, and then filter the produced file list using grep.
Definitely use the mv option on that, istead of rm. That's a really good idea on creating a separate script I can call for this command. Can you explain what exactly the -i and -I options do? Ankit Marothi Ankit Marothi 2 2 bronze badges. AnthonyGeoghegan, yes for instance if there was a directory called ".. And it's not only spaces, it's also other blank characters, newline, single quote, double quote, backslash and file names starting with -.
Ankit, you could start with mywiki. Show 3 more comments. Riya Melvin Riya Melvin The OP asked to keep the contents of the current directory. If you want to remove the main directory as well. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.
Linked Related Hot Network Questions. Question feed. In this case when I use rm -rf , I get the error: rm: Unable to remove directory dir0: File exists The thing is, I do not know where did all those files come from.. I think I did an nfs mount and something went wrong.. I'm sorry to say that the suggestion from "encrypted" really doesn't work. Join Date: Oct In this case when I use rm -rf , I get the error: rm: Unable to remove directory dir0: File exists even in dir0, rm.
Find all posts by milhan. I have all necessary permission. How to skip that questions? Shell Programming and Scripting. Append string to all the files inside a directory excluding subdirectories and. Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude. Remove all the subdirectories except latest 5 inside any given directory. I have tried the following but not worked. Help on Backing up all the files in the subdirectories under a parent directory.
Hi, I am not too familiar with Unix scripting but I have to write code to find all the files under all the sub directories under a parent directory of unix location and move them to the corresponding Windows location.
0コメント