Explain the command ls -1tr | head -n -10 | xargs -d '\n' rm -f --

Taras Shumylo
Taras Shumylo used Ask the Experts™
on
The command is from the post on http://superuser.com/questions/268344/how-do-i-delete-all-but-10-newest-files-in-linux
ls -1tr | head -n -10 | xargs -d '\n' rm -f --

Open in new window

What does the last
--

Open in new window

stands for in this command?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
As always, you should read a command's manpage to find out how it interprets its arguments.

-- is commonly used to indicate the end of the command options. This is especially useful if you want to pass a filename or other argument that begins with -. It's also a good idea to use it before wildcards that might expand to a filename beginning with a hyphen. (For example, try mkdir foo; cd foo; echo >-l; ls *; ls -- *.)

But git diff also uses it to indicate whether an argument is a <commit> (indicating what revision to diff) or a <path> (indicating which file to diff). It can usually guess, but it's possible for a value to be both a valid commit and a valid path. In that case, you can use git diff foo -- to indicate that foo is a commit, or git diff -- foo to indicate that foo is a path.

Author

Commented:
I open man page for xargs and can not find anything about
--

Open in new window

Why it's not on man page?
Top Expert 2015
Commented:
if you open page for rm you see it.
Top Expert 2015

Commented:
imagine deleting files \* and \-rf .... One who wrote the command did very good...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial