Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

%% 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
2  
This question is tagged "linux" –  Paul Jan 24 '12 at 6:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.