31.07.2013 Views

Sistema Operacional Linux - Portal do Professor

Sistema Operacional Linux - Portal do Professor

Sistema Operacional Linux - Portal do Professor

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Cadernos de Informática<br />

38<br />

CURSO DE INTRODUÇÃO AO SISTEMA OPERACIONAL LINUX<br />

Secretaria de Esta<strong>do</strong> de Educação MG<br />

era uma vez...<br />

Sun Feb 19 21:38:06 BRT 2006<br />

mimbar:~/local/wikit/sh-exemplos:28> date >historia<br />

mimbar:~/local/wikit/sh-exemplos:29> cat historia<br />

Sun Feb 19 21:38:16 BRT 2006<br />

mimbar:~/local/wikit/sh-exemplos:30> rm historia<br />

mimbar:~/local/wikit/sh-exemplos:31> cat historia<br />

cat: historia: No such file or directory<br />

mimbar:~/local/wikit/sh-exemplos:32> cat historia 2>erros<br />

mimbar:~/local/wikit/sh-exemplos:33> ls -l<br />

total 4<br />

-rw-r—r— 1 edesio edesio 41 Feb 19 21:44 erros<br />

mimbar:~/local/wikit/sh-exemplos:34> cat erros<br />

cat: historia: No such file or directory<br />

mimbar:~/local/wikit/sh-exemplos:35> cd ..<br />

mimbar:~/local/wikit:36> ls -1<br />

CVS<br />

Index.txt<br />

Pages<br />

dump.log<br />

error.txt<br />

history<br />

linux.see<br />

notes.tkd<br />

rascunho.txt<br />

savelog.txt<br />

sh-exemplos<br />

should-not-be-here-linux.see<br />

tmp<br />

wikit.copia<br />

wikit.tkd<br />

mimbar:~/local/wikit:37> ls -1 | wc -l<br />

15<br />

mimbar:~/local/wikit:38><br />

O que aconteceu acima? Vejamos usan<strong>do</strong> o número <strong>do</strong> coman<strong>do</strong> como referência:<br />

#18 #18 o diretório está vazio<br />

#19 #19 #19 usamos o echo que escreve na saída padrão<br />

#20 #20 redirecionamos a saída o echo para o arquivo historia<br />

#21 #21 da<strong>do</strong>s <strong>do</strong> arquivo cria<strong>do</strong><br />

#22 #22 usan<strong>do</strong> o cat para exibir o conteú<strong>do</strong> <strong>do</strong> arquivo cria<strong>do</strong><br />

#23 #23 contan<strong>do</strong> as linhas, palavras e caracteres <strong>do</strong> arquivo<br />

#24 #24 usan<strong>do</strong> o pipe pipe ao invés de um arquivo intermediário<br />

#25 #25 o cat listan<strong>do</strong> a entrada padrão (porque foi executa<strong>do</strong> sem argumentos)<br />

#26 #26 #26 colocan<strong>do</strong> a data atual no final final <strong>do</strong> arquivo de historia (adiciona<strong>do</strong>)<br />

#27 #27 novo conteú<strong>do</strong> <strong>do</strong> arquivo historia<br />

#28 #28 sobrescreven<strong>do</strong> o arquivo historia, o conteú<strong>do</strong> anterior é perdi<strong>do</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!