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, 2019 in Linux Administration by Upasana
• 8,620 points
1,023 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 8, 2019 by Shubham
• 13,490 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, 2019 in Linux Administration by Omkar
• 69,220 points
3,423 views
0 votes
1 answer

Error: tkinter for Python Installation

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

answered Jul 4, 2019 in Linux Administration by Upasana
• 8,620 points
964 views
0 votes
2 answers

Job for httpd.service failed because the control process exited with error code.

Hi guys I was facing same problem as ...READ MORE

answered Nov 21, 2020 in Linux Administration by anonymous
• 140 points
45,599 views
0 votes
1 answer
0 votes
0 answers

What directory is '~' when I type 'cd ~'?

I'm only new to using SSH, but ...READ MORE

Apr 14, 2022 in Linux Administration by Rahul
• 9,680 points
504 views
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
1,180 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, 2019 in Linux Administration by Shubham
• 13,490 points
2,192 views
0 votes
1 answer

Can I analyze a program's core dump file with GDB when it has command-line parameters?

You can simply use of GDB, to debug ...READ MORE

answered Jul 1, 2019 in Linux Administration by Shubham
• 13,490 points
8,076 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP