[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • 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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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