LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-28-2010, 08:27 AM   #1
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 18.04 / CentOS 7.6
Posts: 397

Rep: Reputation: 62
'find' command regex to exclude hidden files?


I have the following command which finds all files that have changed in the last day and lists them. How can I exclude hidden files like .bash_history?

Code:
find /home/jon -type f -mtime -1 -print
Some sort of regex?

Thanks.
 
Old 06-28-2010, 08:44 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

If you are only interested in removing the dot-files and not the dot-directories:

find /home/jon -not -name "\.*" -type f -mtime -1 -print

If all dot-directories need to be excluded as well:

find /home/jon -type f -mtime -1 -print | grep -v "/\."

Hope this helps.
 
1 members found this post helpful.
Old 06-28-2010, 08:46 AM   #3
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 18.04 / CentOS 7.6
Posts: 397

Original Poster
Rep: Reputation: 62
Thanks very much! I didn't know you could use something like -not...good to know
 
Old 06-28-2010, 08:53 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I make find exclude hidden files (.files) Rotwang Linux - General 2 08-08-2011 03:58 AM
Can we use exclude option in"rm" command to exclude some files/folders? yadav_rk727 Linux - Newbie 1 02-03-2010 10:14 AM
How to exclude certain path from find command. UltraSoul Linux - Software 8 05-16-2009 06:26 PM
Regex to exclude a specific phrase grob115 General 5 11-19-2008 12:10 PM
tar --exclude-from=files command not working cucolin@ Linux - Server 2 04-03-2007 09:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration