0

I have thousands of html file in a directory. I wanna extract files that contain Chennai in the file name and put it into another folder. I am sure it is possible. I am not close enough to copy the files to another folder.

Venkateshwaran Selvaraj
  • 1,745
  • 8
  • 30
  • 60

2 Answers2

1

Use globbing:

mv *Chennai* target/

If the file names might start with a dot, use

mv .*Chennai* *Chennai* target/
choroba
  • 231,213
  • 25
  • 204
  • 289
  • `cp` makes copies, `mv` moves. In this case, you can use the one you like more with the same syntax. – choroba Sep 19 '13 at 07:05
1

Try:

find directory_with_htmls -type f -name "*Chennai*.html" -exec cp {} some_other_folder \;

This would copy html files in the directory_with_htmls directory containing Chennai in the name to the directory some_other_folder.

devnull
  • 118,548
  • 33
  • 236
  • 227