LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 06-21-2005, 10:34 AM   #1
socratesone
LQ Newbie
 
Registered: Jun 2005
Posts: 2

Rep: Reputation: 0
- SOLVED - copy all of one filetype found by locate command to a single directory


I have a few different partitions, all mounted. Some of them are windows, some of them are linux.

I'm using mandrake linux community 10.1 and would like to use one command or a small shell script to copy all true type fonts (ttf or TTF) files found with the locate command into a single directory.

How can I pipe the output of a locate command to the cp command? Something like:

locate -i ttf > ttflist
[for every line in ttflist]
cp line /my/desired/font/path/
[rof]

I'm not really familiar with shell scripts, and I AM learning them, but this seams like there should be a quick solution out there that I can just implement now.

Last edited by socratesone; 06-22-2005 at 01:23 PM.
 
Old 06-21-2005, 10:43 AM   #2
azucaro
Member
 
Registered: Jan 2005
Location: Washington, D.C.
Distribution: Arch (Custom), CentOS
Posts: 238

Rep: Reputation: 30
All you have to change is your path:

locate -i ttf | xargs -iLINE cp LINE /my/desired/font/path/

See "man xargs" for details.
 
Old 06-21-2005, 12:18 PM   #3
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 52
Quote:
Originally posted by azucaro
All you have to change is your path:

locate -i ttf | xargs -iLINE cp LINE /my/desired/font/path/

See "man xargs" for details.
alternatively:
Code:
cp `locate -i ttf` /my/font/path
(those are backticks, not commas)
 
Old 06-22-2005, 01:23 PM   #4
socratesone
LQ Newbie
 
Registered: Jun 2005
Posts: 2

Original Poster
Rep: Reputation: 0
thanks, both of you

thank you!

backticks. That's what I was missing.

The xargs command is a new one for me, as well.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
how to locate file in home directory learnfast Linux - Newbie 3 03-14-2005 07:15 AM
locate and copy files - without directory tree rodda Linux - General 1 01-16-2005 02:10 AM
how do I copy a whoel folder form one directory to another form the command line? zwyrbla Linux - Newbie 8 08-24-2004 06:40 PM
Updatedb and Locate - commands not found rodviking Linux - Software 3 11-17-2003 12:41 AM


All times are GMT -5. The time now is 06:38 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration