hopefully simple 'cp' question
I want to copy all files with the extension .afm from:
/usr/local/texlive/2011/texmf-dist/fonts/afm ...into a single directory. The problem is that they are split into several levels of subdirectories under that directory. There are TONS of subdirectories and levels in that /afm directory and I don't want to have to drill down into each one to copy the files out. Surely there is a simple way to do this but I am not finding it. I have tried: cp *.afm /home/username/afm-files but it doesn't find any afm files to copy as it only looks in the top level directory. can anyone tell me what I'm missing here? |
Oh I have also tried cp -r which I thought would check the subdirectories but no luck there either.
This is the error I get. Code:
username@username [/usr/local/texlive/2011/texmf-dist/fonts/afm] |
You can use the find command
Code:
find startdirectory -iname "filetype" -exec cp {} target_dir \; |
This is a perfect case to use the find command:
Code:
find /usr/local/texlive/2011/texmf-dist/fonts/afm -name "*.afm" -exec cp '{}' /home/username/afm-files \; For more info have a look at Code:
man find |
I will give that a try, thanks!
|
You have to escape the curly brackets, that can simply be done with single quotes '{}'. You also forget the ; at the end of the command, this has also to be escaped, you can do this with single quotes also ';', or you use the backslash \;.
For matching the filename you also need the wildcard *. Code:
find /usr/local/texlive/2011/texmf-dist/fonts/afm -iname "*.afm" -exec cp '{}' /home/username/afm-fonts \; |
Thanks guys, 'find' was exactly what I needed!
|
All times are GMT -5. The time now is 10:44 PM. |