Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
Hello, I am working on a way to try and figure out how to move files to another directory except a few. For example.....
Say I have a directory /home/testuser/stuff and...
1. I have lets say 50 files in that directory...
2. file1, file2, file3,....... file50
3 And I make a direcotry inside ~/stuff called oldstuff
4. Then I want to move all the files in there to oldstuff except files 1 and 2 with one command..
I realize I could move them all in there and then go into "oldstuff" and pull back out the ones I want to the original folder like (#mv file1 file2 ../), but what I am actually doing is working on a more involved than that example, (Just thought that example might help explain better) So I guess Im wondering if there is "except" sort of substitution for the mv command.
Hello, thanks for the reply. I guess Im still somewhat of a newb. I understand the majority of that command, but not all. However, how would that apply to my example? What if for example, all files in that directory where .txt, and I wanted to move all but file1.txt and file2.txt to the other folder with that command. Would I need a -not? Like for example,
The ! is like saying not
Spacing in the command is important, looks like you don't have a space after the last )
When posting code on the forum, it is easier for people to see how your code actually looks if you put it inside code or quote thingys.
The # thing up in the tool bar can be used for code.
Thanks alot Homey for all your replies. That was some good info, I will play around with it a bit and see what I come up with. Thanks also for the # tip. I just saw that in the toolbar as I am replying to this.
Well shoot, Ive been trying this for the last 15 minutes on a practice run. I made a fake scenario with a folder test and testorig and made a 5 files and tried to move 3 of them but not the first two..... heres, what Im trying...
Im not seeing the stray backslash, ive actually tried it every way taking one out at a time and get a syntax error near unexpected token error. Can you please point out where you think I have it wrong?
Thanks!!
EDIT Sorry, replied to soon. Its the backslash before the "-exec" I thought I tried getting rid of that, but guess not. Thanks to all for your replies, it works great!!
Last edited by pccdrussell; 07-21-2007 at 11:10 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.