In several commonly used shell commands can be shortened with convenient alias, a classic example is: alias ll=’ls -al’ Also in this field zsh has some interesting features, which enable you to define traditional aliases but also things a bit more particular. Find me on Google+
It’s funny how through small daily tasks sometimes it happen to find new features or commands that you do not knew not, and today this thing happened to me.
In particular, I had to do something trivial on the shell of a server, run : command1 | tail-n 2 i use tail to keep, from a significant long output, only the last 2 lines which then i use in another function, but beyond this, I needed to understand if command1 was terminated with an exit code of 0 or if the code was not 0 which number it was.
A simple:
.... command1 | tail-n 2 if [$? -ne 0] then echo "command1 failed." EXIT_CODE = 1 fi .... |
Does not work because the exit code comes from the command tail, which in my case is always 0.
So I Googled a bit and found more than a solution for this simple problem.
Continue reading »


