LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Find modified files with special characters (https://www.linuxquestions.org/questions/linux-newbie-8/find-modified-files-with-special-characters-4175441106/)

blaise77 12-12-2012 05:18 AM

Find modified files with special characters
 
Hello Everybody
i am new to linux so excuse my question.
I am trying to find files modified 1 week ago that contain special characters 'pg' and i am stuck
(putty)
i use

find -mtime +7

How do i specify the special characters ['pg']in command

Thanks

bala.linuxtech 12-12-2012 05:23 AM

Quote:

Originally Posted by blaise77 (Post 4847621)
Hello Everybody
i am new to linux so excuse my question.
I am trying to find files modified 1 week ago that contain special characters 'pg' and i am stuck
(putty)
i use

find -mtime +7

How do i specify the special characters ['pg']in command

Thanks

Hi

Try this command

#find -mtime +7 "pg"

or

#find -mtime +7 p*

Hope it will helps you !

chrism01 12-12-2012 05:32 AM

Well pg aren't what we'd normally call 'special', but I'm guessing you mean as part of the filename?
Code:

find . -mtime +7 -name '*pg*'
http://linux.die.net/man/1/find

Special chars are normally non-printable (aka ctrl chars) or meta chars for regular expressions; generally punctuation marks.

HTH

millgates 12-12-2012 05:35 AM

If you mean contain text "pg", I think you'll have to use grep in addition to find. Something like

Code:

    while read fname; do grep -I pg "$fname"; done < <(find . -mtime +7)


All times are GMT -5. The time now is 01:50 PM.