Logo 
Search:

Unix / Linux / Ubuntu Forum

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds

Put some order into a collection of documents

  Date: Nov 25    Category: Unix / Linux / Ubuntu    Views: 441
  

I have been asked to put some order into a collection of documents.
Unfortunately - for me - the people who collected these documents
together had no real idea of document management and so they were all
dumped into three directories, each with well over a thousand files in them.

There is a small ray of light which means that I hopefully won't have to
trawl through each individual file to complete this job. Most (but not
all) of the files have a keyword in their filename and I can classify
them into appropriate directories according to this keyword. I can
easily extract a list of files with any given keyword with

ls -al | grep -i 'keyword'

but my question is this - how can I pipe the output of the above command
to a cp or mv command to only copy/move those files to the desired
directory?

Share: 

 

1 Answer Found

 
Answer #1    Answered On: Nov 25    

The simplest way I know of is using the find command. Find command has a -exec
option for directing the execution of a command on the find 'list' and looks
something like this:

find ./ -name test\* -exec cp {} /home/kevin/test/me \;

this is to find all of the commands with "test" in the name and copy to a
directory.

The syntax can be a little tricky but I have seen this command used a lot in
cases just like yours.

 
Didn't find what you were looking for? Find more on Put some order into a collection of documents Or get search suggestion and latest updates.




Tagged: