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 | f
blah
# df -h | f cat
blah
Filesystem Size Used Avail Use% Mounted on
rootfs 37G 36G 0 100% /
udev 10M 0 10M 0% /dev
tmpfs 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/lock
tmpfs 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?
catis$@