LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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
  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,012

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


Reply



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



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 7 12-19-2015 01:03 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

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:44 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration