O que significa% 1 em “kill% 1” significa?

10

Eu sei que $! armazena o pid do último processo (background), mas o que significa %1 ? Eu geralmente vejo isso junto com kill e tem o mesmo efeito que kill $! . Alguém pode me dar uma dica? (Tais pequenos termos são tão difíceis de pesquisar no Google: - /)

    
por Zardoz 24.04.2011 / 23:48

2 respostas

9

O designador % refere-se aos trabalhos na lista de trabalhos do shell atual e retorna o PID. Experimente help jobs .

    
por 24.04.2011 / 23:50
8

O que você deseja para o Google é man bash

There are a number of ways to refer to a job in the shell. The charac- ter % introduces a job name. Job number n may be referred to as %n. A job may also be referred to using a prefix of the name used to start it, or using a substring that appears in its command line. For exam- ple, %ce refers to a stopped ce job. If a prefix matches more than one job, bash reports an error. Using %?ce, on the other hand, refers to any job containing the string ce in its command line. If the substring matches more than one job, bash reports an error. The symbols %% and %+ refer to the shell's notion of the current job, which is the last job stopped while it was in the foreground or started in the back- ground. The previous job may be referenced using %-. When there is the current job only, %- refers to the shell's notion of the current job. In output pertaining to jobs (e.g., the output of the jobs com- mand), the current job is always flagged with a +, and the previous job with a -. A single % (with no accompanying job specification) also refers to the current job.

Simply naming a job can be used to bring it into the foreground: %1 is a synonym for ''fg %1'', bringing job 1 from the background into the foreground. Similarly, ''%1 &'' resumes job 1 in the background, equivalent to ''bg %1''.

TL; DR: %1 é o trabalho número 1.

    
por 24.04.2011 / 23:53

Tags