![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell script to search for text in a file and copy file | imeadows | UNIX for Dummies Questions & Answers | 9 | 11-12-2008 09:12 PM |
| Recursicely search and rename file extension | riverside | Shell Programming and Scripting | 7 | 04-11-2008 10:02 AM |
| Search for all the unique file extension | riverside | Shell Programming and Scripting | 1 | 04-09-2008 04:47 PM |
| Search for strings & copy to new file | amitrajvarma | Shell Programming and Scripting | 2 | 11-25-2007 11:51 PM |
| string search in folders with particular multiple file extension | anikanch | UNIX for Dummies Questions & Answers | 2 | 10-28-2005 10:09 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
File extension search and copy
Hi need to know if we can write a shell script to find files for a particular format;s ie both .csv and .txt in a particular folder and then copy them to a new folder on a dialy basis. Does anyone know how this can be accomplished?
Thanks, Sandeep |
|
||||
|
Code:
find ./ -name "*.[ct][sx][vt]" -exec cp {} newfolder \;
After . the first character must be c or t (For .csv and .txt files) After . the second character must be s or x (For .csv and .txt files) After . the third character must be v or t (For .csv and .txt files) Anyway, other combinations will also match (like .cxt) which I mentioned in my previous reply. The exec in the above command copies all the found files (i.e, all .csv and .txt files we need) to the directory called newfolder. Note: Better to have newfolder outside the current directory and not as a subdirectory in the present directory. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|