seen it more in Windows than Linux but nonetheless I was always curious what does the % mean/do? Thanks
In what context?
in scripts…now I’m even more curious what other context could there be?
In searches it usually means ‘any number of characters’; so %word% means 'find ‘word’ with any number of characters before and after it. word% means find ‘word’ at the start but with any number of characters after it.
The % character is of course as you know, the percent sign. So like many other punctuation characters, it’s pressed into service to indicate something special in computer languages. So the meaning depends on the language. I believe in DOS BAT scripts, it’s used to surround parameters, but it’s been so long since I wrote a BAT file.
In RPM spec files, it starts a macro. In bash scripts it’s used in substitutions. In SQL it’s used with the LIKE operator. In C printf statements it begins a format specifier. So there are as many interpretations as there are contexts.
alright elaborate a bit…when I click on my k3b icon settings on my desktop and browse to the command path it is k3b %U (I’ve seen the %U in alot of command shortcuts) what exactly does the %U mean? because it doesn’t seem to fit the description of the command you gave me. Thanks
ah wow ken do I have alot to learn…I thought that special characters were pretty universal…guess not.
In the context of a good whisky it means something clearly above 40.
It’s a substitution indicator. You should look up the KDE docs in connection with launchers, but I think %U means substitute the path of the object that triggered this launcher, e.g. the ISO file. So the k3b program will get called with the path as the first argument.
That must also be in some context. In any case not in regular expressions. When I do a search for files having names with word somewhere in them with find, it would be something like
find ./ -name '*word*'
BTW in an URL the % is preceding a hex code for a character outside the allowed character set for an URL.
> I thought that special characters were pretty universal…guess not.
the % is universal in that they always mean the same thing in the
but, they do not mean the same thing, nor can they be used for the
same purpose in every context within the time/space continuium we
call “the universe” (containing earth, Mars, sun, the stars and etc)…
not even 1% of the time…heh!
BTW, escape characters are implicated in some application bugs, such as shell injection and SQL injection. If you are of a philosophical turn of mind, you will see the connection with
Biggles dictates a letter. That is to say, the question of when is a symbol literal and when is it meta? If there is a mistake in differentiating these, it gives rise to a vulnerability.
I know the OP found the answer they were looking for, however, just to
give another example: in Matlab code or in LaTeX files % is used to
state the rest of the line is a comment.
Sorry, hcw, I should have said that I use it most often for simple searches in mysql where you can also use regex which distinguishes ^ for beginning and $ for end.