Find and delete files using “find” shell command


Find and Delete Files in Linux/Unix:

Examples:

1) Find .log files in current directory and delete

$ find . -name “*.log” -type f -exec rm {} \;

2) Find the directories starting with ERO and delete

$ find -name “ERO*” -type d -exec rm {} \;

3) Find .log files in current directory and delete interactively

$ find . -name “*.log” -type f -exec rm -i {} \;

Advertisements

Tags: , ,

About Vaibhav

Friendly & Co-operative.

One response to “Find and delete files using “find” shell command”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: