LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-27-2008, 05:52 AM   #1
hocheetiong
Member
 
Registered: Jul 2007
Location: Penang , Malaysia.
Distribution: red hat linux
Posts: 133

Rep: Reputation: 15
Smile in copy files or ls files the command want to invert select some files how to??


Hi, in my folder have 5 files,example: 1.txt, 2.txt, 3.doc, 4.jpg, 5.cap than if i want to copy all 4 files but exclude file name "5.cap" how to issue the correct command?

if want to list files command is ls, than want to filter some files but list other file in specify folder, what is the correct command?

Thank you.
 
Old 06-27-2008, 07:03 AM   #2
pr00t
LQ Newbie
 
Registered: May 2003
Distribution: SuSE 9.0
Posts: 7

Rep: Reputation: 0
Try this:

ls | grep -v 5.cap | xargs cp --target-directory=/tmp
 
Old 06-27-2008, 07:29 AM   #3
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
Quote:
ls | grep -v 5.cap | xargs cp --target-directory=/tmp
Should be
ls -1| grep -v "5\.cap" | xargs cp --target-directory=/tmp

Last edited by nx5000; 06-27-2008 at 07:30 AM.
 
Old 06-27-2008, 07:32 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
...or "find directory -type something -not -iname somethingElse -exec doSomething {};"
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find files and copy the found files to the floppy in one command justmehere Linux - Newbie 11 05-05-2008 12:29 AM
rsync syntax to skip directory, but copy select files.. tnicol Linux - Software 3 07-24-2007 06:40 AM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 03:27 PM
Copy select files with command line Storyman Linux - Newbie 5 01-23-2007 04:35 AM
Mepis, copy files to thumb drive, files deleted? vremenno Linux - Newbie 6 09-16-2006 12:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:06 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