In the above example, ls wrote the following contents to the pipe for grep: a (Files with spaces in them Some File Name will be excluded by the grep.) For a contrived example to show the point: cd ~/tmp/usr/bin This runs into immediate trouble as soon as any filenames (unlikely as these are to be in /usr/bin) contain a newline. Where you ask ls for the filenames, then have grep filter ones that start ( ^) and end ( $) with only lower-case letters - zero or more of them ( *) you then ask xargs to grep each incoming filename for the string 'file'. Your assignment may expect you to grep the output of ls, perhaps something like this: cd /usr/bin