Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've seen people use kill %% rather than kill %. As far as I can tell, they both do the same. Is there a difference?

share|improve this question
up vote 5 down vote accepted

Quoting the documentation:

There are a number of ways to refer to a job in the shell. The character % introduces a job specification (jobspec). 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 example, %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 background. The previous job may be referenced using %-. If there is only a single job, %+ and %- can both be used to refer to that job. In output pertaining to jobs (e.g., the output of the jobs command), 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.

(emphasis mine)

share|improve this answer
So essentially, both %% and % refer to the current (most recent) job. Good to know that %% is also valid - I suspected the second % was not necessary. – eapen Jan 24 '12 at 16:31

%% is used in windows scripts to mean a '%', as % is a special character. However windows script interpreters also try to be clever and if a % is given all by itself with white spaces around it then it's treated as a %.. It's annoying and goofy but there you go.

share|improve this answer
This question is tagged "linux" – Paul Jan 24 '12 at 6:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .