betabug... Sascha Welter

home english | home deutsch | Site Map | Sascha | Kontakt | Pro | Weblog | Wiki

21 May 2008

find, sed, and xargs in the same command line

How geeky can you get?

A simple problem for some shell fun: I get handed a folder full of folders, each of the child folders containing one font file (.otf file). The child folders names contain spaces. I want all those .otf files in one single folder, but I don't want to go through all the folders with the mouse and drag and drop them over (that's so 1980s).

Instead I spent some time (probably more than drag and dropping would have taken) to try and assemble this puppy of a command line:

find . -name *.otf -print | sed -e 's/.*/"&"/' | xargs -J % mv % ../mpr/

With find, sed, and xargs all in the same one liner, total command line geek fun ensues!

Posted by betabug at 13:38 | Comments (1) | Trackbacks (0)
ch athens
Life in Athens (Greece) for a foreigner from the other side of the mountains. And with an interest in digital life and the feeling of change in a big city. Multilingual English - German - Greek.
Main blog page
Recent Entries
Best of
Some of the most sought after posts, judging from access logs and search engine queries.

Apple & Macintosh:
Security & Privacy:
Misc technical:
Athens for tourists and visitors:
Life in general:
<< Surprise! Surprise! | Main | USB2 Really Is Slower Than FireWire >>
Re: find, sed, and xargs in the same command line

find . -name "*.otf" -exec mv '{}' ../mpr/ \;

Posted by: Saad at May 21,2008 16:42
You can trackback to:
There are no trackbacks.