I am trying to understand the above command.
sudo /bin/ls %s %file_path
-
What is does
%
do? Is it some kind of substituting mechanism? -
What does
sudo /bin/ls
do?
sudo
I am trying to understand the above command.
sudo /bin/ls %s %file_path
What is does %
do? Is it some kind of substituting mechanism?
What does sudo /bin/ls
do?
Best Answer
% in bash scripting stands for anchoring, but it can sometimes vary between programs what it does as a part of some parameter or another. For ls it does nothing. For sudo it does some things, but not in this context; it is making no sense to me... this command simply tries to (as root; for the record, you almost never have to run ls as root, there are very few places where filenames can not be accessed by normal users through ls) search directories %s and %foo for files, and should give us the result of "ls cannot access %s: No such file or directory" and much the same for %foo. (There can never be directory %s unless you created it)
For scripting it does the below.
From http://wiki.bash-hackers.org/syntax/pe:
Anchoring Additionally you can "anchor" an expression: A # (hashmark) will indicate that your expression is matched against the beginning portion of the string, a % (percent-sign) will do it for the end portion.
(What the code is doing is that it is trading either the first or the last "x" out for an "y")