I have an example where I define a function named f which prints blah and then stores command itself and all its arguments into variable $@:# f () { echo blah; $@; }# df -h | fblah# df -h | f catblahFilesystem                                              Size  Used Avail Use% Mounted onrootfs                                                   37G   36G     0 100% /udev                                                     10M     0   10M   0% /devtmpfs                                                   304M  308K  303M   1% /run/dev/disk/by-uuid/466fbdef-029c-4625-8bb2-cde3acd77e55   37G   36G     0 100% /tmpfs                                                   5.0M     0  5.0M   0% /run/locktmpfs                                                   2.1G     0  2.1G   0% /run/shm/dev/sda2                                                74G  7.0G   63G  11% /home/dev/sr1                                                5.6M  5.6M     0 100% /media# How does this f cat part on the right of the pipe work? How does the stdout of df -h end up in the $@ variable? Why does cat print the content of the $@ variable?
Understand the order of commands in bash when functions are involved
bash
In:df -h | fYou redirected df -h output to f standard in, then called f without any arguments, $@ is empty.In other hand:df -h | f catYou redirected df -h output to f standard in, then called f with one argument cat. $@ inside f expanded to cat. cat concatenated standard in, which is df -h output, to standard out.