Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Find file that contains "....." (command in Unix)

by robartes (Priest)
on Mar 28, 2003 at 07:50 UTC ( [id://246423]=note: print w/replies, xml ) Need Help??


in reply to Find file that contains "....." (command in Unix)

No Perl needed solution:
find . -type f -exec grep "\.\.\.\.\." /dev/null {} \;
Or if you have a modernish grep:
grep -r "\.\.\.\.\." .

Update: The OP requested the file name, the solutions print all lines containin the pattern. This does what the OP wants:

find . -type f -exec grep -q "\.\.\.\.\." {} \; -exec echo 'Found {}' + \;

CU
Robartes-

Replies are listed 'Best First'.
Re: Re: Find file that contains "....." (command in Unix)
by parv (Parson) on Mar 28, 2003 at 10:46 UTC

    Well, here is yet another solution assuming gnu grep...

    grep -F -r -I -l '.....' . | grep '.txt$'

    ...first part of the pipeline recursively, -r, (downword only) searches text files, -I, for ..... in the current directory, ., listing only the file names found. Second part filters the file names which lists only those ending in '.txt'.

    Here is one more and bit more robust (to be run in "test" directory; see OP)...

    find . -type f -name '*.txt' -print0 | xargs -0 grep -F -l '.....'
Re: Re: Find file that contains "....." (command in Unix)
by waswas-fng (Curate) on Mar 28, 2003 at 15:45 UTC
    or just find . -type f -exec grep -lq "\.\.\.\.\." {} \;

    -Waswas

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://246423]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-16 19:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found