Feb 222012
 

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 »

flattr this!

Dec 052010
 

terminalSometimes it happen to find in our file system files with strange names, with that i means files with non-alphanumeric characters or spaces between different words, maybe uploaded by users, or files produced by mistake by someone or some program, and unfortunately is often not trivial to do a mv < file > or rm < file >.

Let’s see how to get rid of these horrors. Continue reading »

flattr this!

Nov 182010
 

history

The history command is very useful when you frequently work at the terminal and you want to invoke a command given in the past.But there are several options that are not so common or poorly understood, in this article we’ll see some of them in bash and zsh.

Basic usage

Show last commands in history.

Apply to bash and zsh

history

Continue reading »

flattr this!

Alias in Zsh

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+

Globbing with zsh

In a previous article we saw how to install and configure zsh, today we’ll see in detail the options offered by the zsh for globbing or how the shell use some special characters to auto-complete our commands. Please note: most command you’ll see here could be accomplished with particular switch of the command, for example [...]