Question: I have some text files in a directory. I would like to read all the files in this directory and if the file has the following line

`SAMPLE 350 AN INTEGER OF TYPE :DECIMAL : CAN BE ASSEMBLED BY` move that file with its all contents to another directory.

How can I do this?

Answer: 
Using `find` and `grep`:

```
$ find . -type f -exec \
  fgrep -l "SAMPLE 350 AN INTEGER OF TYPE :DECIMAL : CAN BE ASSEMBLED BY" {} \; \
  | xargs -i%  mv % /path/to/new/dir

```
Here is a solution in python. The os.path.isdir() was necessary to bypass subdirectories. The "and file[-3:] != '.py'" is needed if running this .py script from the source directory. Alternately you could just check for the name of the script if you need to move .py files.

```
import os
import shutil

src = '/source'
dst = '/destination'
pattern = 'SAMPLE 350 AN INTEGER OF TYPE :DECIMAL : CAN BE ASSEMBLED BY'
for file in os.listdir(src):
  if not os.path.isdir(file):
    f = open(file)
    for line in f:
      if pattern in line and file[-3:] != '.py':
        f.close()
        shutil.move(file,dst)
        break
    f.close()

```