• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

Remove jpg and text files at command line

I am using the following line to remove jpg files in subdirectories using the sh shell

find dir1 dir2 -name '*jpg' -exec rm -f {} \;

What is the proper way to change this command to include txt files as well?
0
pda4me
Asked:
pda4me
2 Solutions
 
amit_gCommented:
find dir1 dir2 \( -name '*.jpg' -o -name '*.txt' \) -exec rm -f {} \;

Run

find dir1 dir2 \( -name '*.jpg' -o -name '*.txt' \) -print \;

before to confirm that the command is working correctly.
0
 
ozoCommented:
find dir1 dir2  \( -name '*jpg' -o  -name '*.txt' \)  -exec rm -f {} \;
0
 
pda4meAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now