De acordo com as Leis 12.965/2014 e 13.709/2018, que regulam o uso da Internet e o tratamento de dados pessoais no Brasil, ao me inscrever na newsletter do portal DICAS-L, autorizo o envio de notificações por e-mail ou outros meios e declaro estar ciente e concordar com seus Termos de Uso e Política de Privacidade.

Argumentos em Shell Scripts (Bourne Shell) (4)

Colaboração: Rubens Queiroz de Almeida

Data de Publicação: 03 de Junho de 1997

$$

Identificação do processo executando a shell. Bastante útil para criação de arquivos temporários.

Por exemplo:

  tmpfile=/tmp/file$$
  sed -e "s/$DE/$FROM" $1 > $tmpfile
  mv $tmpfile $1

No exemplo acima, o arquivo fornecido como argumento na linha de comandos é editado pelo comando sed, onde todas as strings identificadas pela variável $DE são substituídas pela string identificada pela variável $PARA e a saída é gravada no arquivo /tmp/file$$ ($tmpfile).

Após a execução do comando sed o arquivo temporário é novamente gravado como $1 (arquivo original).


Dica Humorística :-)

What is a Unix Guru?

People who come into contact with the UNIX system are often told: ``If you have trouble, see so-and-so, he's a guru, or ``Bob there is a real hacker. Often, they are baffled by these appelations, and do not pursue the matter further. What is a Unix Hacker? How does he differ from a Guru? To answer these and other questions, I present a draft of the Unix Hierarchy:

BEGINNER

insecure with the concept of a terminal has yet to learn the basics of |vi| hasn't figured out yet how to get a directory still has trouble with typing at the end of each line

NOVICE

knows that ls will produce a directory uses the editor, but calls it `vye' has heard of C but never used it has had his first bad experience with rm is wondering how to read his mail is wondering why the person next to him seem to like Unix so much

USER

uses vi and nroff, but inexpertly has heard of regular-expression but never seen one uses egrep to search for fixed strings has figured out that - precedes options is wondering how to move a directory has attempted to write a C program and decided to stick with Pascal thinks that dbx is a brand of stereo component knows how to read his mail and wonders how to read news

KNOWLEDGEABLE USER

uses nroff without trouble, and is beginning to learn tbl and eqn thinks that fgrep is `fast grep' has figured out that mv will move directories has learned that learn doesn't help someone has shown him how to write C programs once used sed to do some text substitution has seen dbx used but doesn't use it himself thinks that make is for wimps

EXPERT

uses sed when necessary uses macros in vi, uses ex when necessary posts news at every possible opportunity writes csh scripts occasionally writes C programs with vi and compiles them with cc has figured out what && and || are for thinks that human history started with !h

HACKER

uses sed and awk with comfort uses undocumented features of vi writes C code with cat > and compiles with !cc use adb because he doesn't trust source debuggers can answer questions about the user environment writes his own nroff macros to supplement standard ones writes scripts for Bourne shell

GURU

uses m4 and lex with comfort writes assembly code with cat > uses adb on the kernel while the system is loaded customizes utilities by patching the source reads device driver source with his breakfast can answer any Unix question after a little thought uses make for anything requiring two or more distinct commands to achieve has learned how to breach security, but no longer needs to try

WIZARD

writes device drivers with cat > fixes bugs by patching the binaries can answer any question before you ask writes his own troff macro packages is on a first-name basis with Dennis, Bill and Ken

Adicionar comentário

* Campos obrigatórios
5000
Powered by Commentics

Comentários

Nenhum comentário ainda. Seja o primeiro!


Veja a relação completa dos artigos de Rubens Queiroz de Almeida