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.
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.
|
|
04-05-2006, 03: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, 04: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, 04: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 05:01 PM.
|
|
|
04-05-2006, 05: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, 05:29 PM
|
#5
|
LQ Newbie
Registered: Apr 2005
Posts: 29
Original Poster
Rep:
|
Thanks!
I'll try find with exec option!
|
|
|
04-05-2006, 08: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, 10:13 PM
|
#7
|
LQ Newbie
Registered: Apr 2005
Posts: 29
Original Poster
Rep:
|
wow!
I'll try it, thanks
|
|
|
04-07-2006, 03:45 PM
|
#8
|
Senior Member
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012
Rep:
|
"find <opts> -print0 | xargs -0 <command>" handles newlines in filenames.
|
|
|
All times are GMT -5. The time now is 03:42 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
|
|