Browsed by
Tag: bash

How to use command line on Mac OS X

How to use command line on Mac OS X

A friend of mine (who came from Windows world) have bought a Mac recently and he asked me how to use command line on Mac OS X:

My answer was:

1) 99% of commands are identical in Linux. This is good news as there are a lot of material about it available on the Internet;

2) Terminal.app from OS X is cool, but it’s not perfect. I (and 90% of developers I know) use iTerm2 (http://iterm2.com/). It’s light (3mb), free, open-source, has a better interface than the native one and it rocks! Best terminal I’ve ever used.

3) This is the most useful topic in my answer: an awesome cheat-sheet with command line commands made by the Git-tower team;

4) To finish: I’ve recorded a screencast showing up how to create scripts in OS X and Linux (similar to BAT file in Windows). Unfortunately this is only available in portuguese:

Criando um log com detalhes de erros

Criando um log com detalhes de erros

Quando rodamos algum script em sistemas Unix, existem 3 tipos de mensagens de entrada e saída:

  • STDIN – Standard in (código 0)
  • STDOUT – Standard out (código 1)
  • STDERR – Standard error (código 2)

Se você precisar salvar um log contendo não só as mensagens da saída padrão, mas também as mensagens de erro, use o seguinte sufixo: 2>&1, assim:

ls -lR / > /tmp/file.log 2>&1

O que estamos fazendo aí é pegando tudo que é da saída 2 (STDERR) e jogando pra saída 1 (STDOUT), fazendo com que o log contenha tudo :)

Valeu Wagnão pela dica!