Wednesday, 2 May 2012

Linux/Mac - Find files by filetype and move them into a target directory


Find (find) all text files ('*.txt') in the current directory (.) by case-insensitive filename (-iname) and display the output in the console (-print).
Code Snippet
  1. find . -iname '*.txt' -print
End of Code Snippet


Find (find) all text files ('*.txt') in the current directory (.) by case-insensitive filename (-iname) and (-exec) move each one of them (mv {}) to the temp directory (/tmp).
Code Snippet
  1. find . -iname '*.txt' -exec mv {} /tmp \;
End of Code Snippet

No comments: