Slackware This Forum is for the discussion of Slackware Linux.
|
| 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
04-05-2006, 02:54 PM
|
#1
|
|
LQ Newbie
Registered: Apr 2005
Posts: 29
Rep:
|
How to "cp" or "rm" or "tar" all the files except a certain file?
Hi,
There're many files in a folder:
1.a
2.b
3.c
4.d
.
.
.
999.xyz
I want to cp *.* except one of them, or rm *.* except one of them, or tar *.* except one of them.
Is there any simple command or option could do it?
Thanks!
|
|
|
|
04-05-2006, 03:06 PM
|
#2
|
|
Member
Registered: Feb 2005
Location: Ontario, Canada
Distribution: Gentoo, Slackware
Posts: 345
Rep:
|
RTFM!!!!
No really.
From the man page:
Code:
-X file
--exclude-from file Exclude files listed in file.
|
|
|
|
04-05-2006, 03:58 PM
|
#3
|
|
LQ Newbie
Registered: Apr 2005
Posts: 29
Original Poster
Rep:
|
Thank you!
It only works for 'tar', when I use this:
rm *.* -X aaa
or
rm *.* --exclude-from aaa
it shows:
invalid option -- X
or
unrecognized option '--exclude-from'
I already RTFM of 'cp' and 'rm', no information yet!
Last edited by cqmyg5; 04-05-2006 at 04:01 PM.
|
|
|
|
04-05-2006, 04:19 PM
|
#4
|
|
Member
Registered: Nov 2004
Location: Columbus, Ohio
Distribution: Slackware-Current / Debian
Posts: 795
Rep:
|
Why not use find with the exec option or just move the file you want to keep?
|
|
|
|
04-05-2006, 04:29 PM
|
#5
|
|
LQ Newbie
Registered: Apr 2005
Posts: 29
Original Poster
Rep:
|
Thanks!
I'll try find with exec option!
|
|
|
|
04-05-2006, 07:52 PM
|
#6
|
|
Member
Registered: Jul 2001
Distribution: Slackware 12
Posts: 511
Rep:
|
Or maybe
Code:
ls | grep -v file | xargs rm
|
|
|
1 members found this post helpful.
|
04-05-2006, 09:13 PM
|
#7
|
|
LQ Newbie
Registered: Apr 2005
Posts: 29
Original Poster
Rep:
|
wow!
I'll try it, thanks
|
|
|
|
04-07-2006, 02:45 PM
|
#8
|
|
Senior Member
Registered: Jul 2005
Distribution: Slackware
Posts: 2,006
Rep: 
|
"find <opts> -print0 | xargs -0 <command>" handles newlines in filenames.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:11 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.
|
Latest Threads
LQ News
|
|