Question: I'm writing a script to retrieve files from a commit under myDir directory but i can't get it to work here's the script :

```
echo "************* $commit ******************      "
        list_files = `git diff-tree --no-commit-id --name-only -r $commit | grep myDir`
        for file in $list_files
            do
                echo "File name is : $file "
        done

```

I always get an error in list\_files saying that : 

> 
> list\_files: command not found
> 
> 
>

Answer: 
Remove the space before and after = 

```
list_files = `git diff-tree

```

should be

```
list_files=`git diff-tree.....`

```

Say, if `x=10` is given as `x = 10`, then shell will think `x` is a command called with 2 arguments. Since there is no such command called `x`, it gives the error command not found.
Your approach is too complicated. Try

```
git ls-files $commit myDir | while read f; do
  echo "file name is $f"
done

```

The improvements are:

* A simpler Git command specifically invented to list files in the specified commit under the specified prefix.
* You process the files output by that command as it outputs them —
instead of saving all the output into a giant string and then splitting it again.