Argument receiving error for rm command

0 votes

I have several hundred PDFs under a directory in UNIX. The names of the PDFs are approx. 60 chars.

When I try to remove them all together using rm -f *.pdf

I get the following error:

/bin/rm: cannot execute [Argument list too long]

What can I do?

Jun 7 in Linux Administration by Upasana
• 8,570 points
42 views

1 answer to this question.

0 votes

Bash actually expands the asterisk to every matching file, producing a very long command line. That's the reason for your issue.

find . -name "*.pdf" -print0 | xargs -0 rm

This should help

answered Jun 7 by Shubham
• 13,350 points

Related Questions In Linux Administration

–1 vote
1 answer

How to use help command for ls?

The help command is limited and it ...READ MORE

answered Jan 3 in Linux Administration by Omkar
• 68,480 points
510 views
0 votes
1 answer

Error: tkinter for Python Installation

It isn't easy to install Tkinter locally ...READ MORE

answered Jul 3 in Linux Administration by Upasana
• 8,570 points
51 views
0 votes
1 answer

Constraints for getting commands executed by cron

I think the problem could be those ...READ MORE

answered Nov 14, 2018 in Linux Administration by nirvana
• 3,060 points
61 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
101 views
0 votes
1 answer

Linux command-line call not returning what it should from os.system?

What gets returned is the return value ...READ MORE

answered Aug 29, 2018 in Python by Priyaj
• 57,300 points
45 views
0 votes
1 answer

CentOS Error: 64 bit bad ELF interpreter

In my experience, a single yum command will ...READ MORE

answered Jun 20 in Linux Administration by Shubham
• 13,350 points
167 views
0 votes
1 answer