~:: kalyan ::~

May 11, 2006

Collect your files

Filed under: General — skalyanasundaram @ 7:01 pm

Hey, have you got a work of collecting all pdf files (whatever..) from the entire disk at any time?..
If then what u have done? . may i know that… there is a brillient solution(obviously in linux only)
Linux fundoos do not scold me for these kind of basic commands.
Here i want to say the power of linux and the hands on techniques to the poor windows users..

just type
bash # mkdir backup
bash # find / -name “*.pdf” -exec cp {} .\backup \;

do i need to explain this? anyway

find – command to search
/ – start from “/” directory (“.” for current directory)
-name -specifies what are u going to search

do man find for more .. I dont want to reproduce the man page here.

and the output will be the absolute path of the files. That will passed to next command.
exec – u may understand that this to invoke or launch other programs
so a cp command executed ( u can invoke whatever the command u want)

{} – taks the input from the find command..
so p {} .\backup will be interpreted as cp /opt/firefox/doc.pdf .\backup ..
so whenever there is a file found there is a copy command is issued
This is how u can do it…
Now the windows usrs tell me what u have done..?? 🙂

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: