3
1
I've seen people use kill %%
rather than kill %
. As far as I can tell, they both do the same. Is there a difference?
3
1
I've seen people use kill %%
rather than kill %
. As far as I can tell, they both do the same. Is there a difference?
5
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)
-4
%% 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.
2This question is tagged "linux" – Paul – 2012-01-24T06:01:53.620
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 – 2012-01-24T16:31:28.800