LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 04-05-2006, 02:54 PM   #1
cqmyg5
LQ Newbie
 
Registered: Apr 2005
Posts: 29

Rep: Reputation: 15
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!
 
Old 04-05-2006, 03:06 PM   #2
geeman2.0
Member
 
Registered: Feb 2005
Location: Ontario, Canada
Distribution: Gentoo, Slackware
Posts: 345

Rep: Reputation: 30
RTFM!!!!

No really.
From the man page:
Code:
   -X file
   --exclude-from file     Exclude files listed in file.
 
Old 04-05-2006, 03:58 PM   #3
cqmyg5
LQ Newbie
 
Registered: Apr 2005
Posts: 29

Original Poster
Rep: Reputation: 15
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.
 
Old 04-05-2006, 04:19 PM   #4
mdarby
Member
 
Registered: Nov 2004
Location: Columbus, Ohio
Distribution: Slackware-Current / Debian
Posts: 795

Rep: Reputation: 30
Why not use find with the exec option or just move the file you want to keep?
 
Old 04-05-2006, 04:29 PM   #5
cqmyg5
LQ Newbie
 
Registered: Apr 2005
Posts: 29

Original Poster
Rep: Reputation: 15
Thanks!

I'll try find with exec option!
 
Old 04-05-2006, 07:52 PM   #6
Wynd
Member
 
Registered: Jul 2001
Distribution: Slackware 12
Posts: 511

Rep: Reputation: 32
Or maybe
Code:
ls | grep -v file | xargs rm
 
1 members found this post helpful.
Old 04-05-2006, 09:13 PM   #7
cqmyg5
LQ Newbie
 
Registered: Apr 2005
Posts: 29

Original Poster
Rep: Reputation: 15
wow!

I'll try it, thanks
 
Old 04-07-2006, 02:45 PM   #8
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,008

Rep: Reputation: 110Reputation: 110
"find <opts> -print0 | xargs -0 <command>" handles newlines in filenames.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 6 03-21-2013 10:35 AM
what is "sticky bit mode" , "SUID" , "SGID" augustus123 Linux - General 10 08-03-2012 04:40 AM
Telling people to use "Google," to "RTFM," or "Use the search feature" Ausar General 77 03-21-2010 11:26 AM
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 03:07 PM
"X-MS" cant open because "x-Multimedia System" cant access files at "smb&qu ponchy5 Linux - Networking 0 03-29-2004 11:18 PM


All times are GMT -5. The time now is 12:01 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration