I would like to pipe a function with normal commands in Linux. Please note that all these commands are put into a .sh script (I use Bash shell). For example, I have with me a command as follows:

`git diff --name-only HEAD~1..HEAD -z | xargs -0 dirname | catch_exceptions >> extracted_dir_names`

I have written `catch_exceptions` as a function above this command and it contains 2 sed delete statements. If i pipe the two sed commands in the function they work but if i put them one after the other they don't. Could someone explain why it is like this and how a work around can be done? Thanks in advance. 

This works:

```
function catch_exceptions {

    sed '/^\./d' | sed '\#this/path/alone#d'
}

pushd /path/to/direc
rm -f extracted_directories.txt
git diff --name-only HEAD~1..HEAD -z | xargs -0 dirname | remove_duplicates | catch_exceptions >> extracted_directories.txt
cat extracted_directories.txt
popd
}

```

But when i replace catch\_exceptions with:

```
function catch_exceptions {
    sed '/^\./d' 
    sed '\#this/path/alone#d'
}

```

it doesn't work.