The Computer Oracle

What does %1 in "kill %1" mean?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Realization

--

Chapters
00:00 What Does %1 In &Quot;Kill %1&Quot; Mean?
00:24 Accepted Answer Score 15
00:38 Answer 2 Score 10
02:10 Thank you

--

Full question
https://superuser.com/questions/275433/w...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#bash #kill

#avk47



ACCEPTED ANSWER

Score 15


The % designator refers to the jobs in the current shell's job list, and returns the PID. Try help jobs.




ANSWER 2

Score 10


What you want to Google is 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 is job number 1.