nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

copying files from subdirectories

This is a discussion on copying files from subdirectories within the Shell scripting forums, part of the Development/Scripting category; I have Cd which has many folders & subfolders(which have more subfolder in which there are different files like .spc, ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 09-18-2005, 12:48 AM
Junior Member
User
 
Join Date: Sep 2005
Posts: 24
Rep Power: 0
kavi
Default copying files from subdirectories

I have Cd which has many folders & subfolders(which have more subfolder in which there are different files like .spc, .img, .txt etc. Now i want to copy all the .txt files from these folders, subfolder, sub-subfolders. simply put- i want all the .txt files from the CD ROM.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-18-2005, 01:22 AM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Try following small shell script

Code:
a=$(find /mnt/cdrom -name "*.txt")
for i in $a
do
cp $i /tmp
done
Replace /mnt/cdrom with your cdrom mount point, /tmp with actual location where you wanna put all *.txt file
Reply With Quote
  #3 (permalink)  
Old 09-18-2005, 01:37 AM
Junior Member
User
 
Join Date: Sep 2005
Posts: 25
Rep Power: 0
charvi
Default

How abt following one line code?

Code:
find /cdrom -name "*.txt" | xargs -i cp -v {} /home/charvi
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Linux Recursively Delete Subdirectories raj Linux software 0 04-22-2008 02:50 AM
Routing/copying data from eth0 and send over eth1 and eth2 theVOID Networking, Firewalls and Security 2 04-14-2008 06:02 PM
Shell script for automatic conversion of files in tar files kasimani Shell scripting 2 02-08-2007 04:45 PM


All times are GMT +5.5. The time now is 06:02 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36