Sponsored Content
Operating Systems Linux Search only text files with 'find' command? Post 302698063 by Collider on Saturday 8th of September 2012 12:11:56 AM
Old 09-08-2012
Question Search only text files with 'find' command?

I've been using this to search an entire directory recursively for a specific phrase in my code (html, css, php, javascript, etc.):

Code:
find dir_name -type f -exec grep -l "phrase" {} \;

The problem is that it searches ALL files in the directory 'dir_name', even binary ones such as large JPEG images. With a directory also containing large number of images dispersed everywhere, it dramatically reduces the efficiency. Sometimes it takes very long to get a response.

Is there any parameter I can easily use to make it only search text files?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To search for a text in until i find that

In a CSH, i need to write a loop to seach continuously for text "Started" and then only exit from the loop when ever if finds that. Can someone please suggest how we can write this Thanks, Sateesh (3 Replies)
Discussion started by: kotasateesh
3 Replies

2. UNIX for Advanced & Expert Users

find file with date and recursive search for a text

Hey Guyz I have a requirement something like this.. a part of file name, date of modification of that file and a text is entered as input. like Date : 080206 (MMDDYY format.) filename : hotel_rates text : Jim now the file hotel_rates.ZZZ.123 (creation date is Aug 02 2006) should be... (10 Replies)
Discussion started by: rosh0623
10 Replies

3. UNIX for Dummies Questions & Answers

sorting files with find command before sending to text file

i need help with my script.... i am suppose to grab files within a certain date range now i have done that already using the touch and find command (found them in other threads) touch -d "$date_start" ./tmp1 touch -d "$date_end" ./tmp2 find "$data_location" -maxdepth 1 -newer ./tmp1 !... (6 Replies)
Discussion started by: deking
6 Replies

4. Shell Programming and Scripting

Using find command to search a pattern in group of files

Hi i am having a group of *.csh files under parent directory. Now i want to search a particular pattern in these group of *.csh files(suppose i need to search a pattern ABC - proj ). Can anyone please tell me how to do it using find command. Thanks in advance sarbjit (4 Replies)
Discussion started by: sarbjit
4 Replies

5. Shell Programming and Scripting

Find and add/replace text in text files

Hi. I would like to have experts help on below action. I have text files in which page nubmers exists in form like PAGE : 1 PAGE : 2 PAGE : 3 and so on there is other text too. I would like to know is it possible to check the last occurance of Page... (6 Replies)
Discussion started by: lodhi1978
6 Replies

6. Shell Programming and Scripting

smart search through find command

The requirement here is i'm searching for a particular word from the log file between two time stamp. The process for particular account will happen, so i need to see there is any error occurred in between before it completes. in the below code yyyyy and xxxxx are two unique fields. initially... (1 Reply)
Discussion started by: Amutha
1 Replies

7. Shell Programming and Scripting

Find command to search files in a directory excluding subdirectories

Hi Forum, I am using the below command to find files older than x days in a directory excluding subdirectories. From the previous forums I got to know that prune command helps us not to descend in subdirectories. Though I am using it here, not getting the desired result. cd $dir... (8 Replies)
Discussion started by: jhilmil
8 Replies

8. Shell Programming and Scripting

Find command to search and delete files older than 1 days at a desired location

Hello All, Can someone please help me out in creating the find command to search and delete files older than 1 days at a desired location. Thanks in advance for your help. (3 Replies)
Discussion started by: Pandee
3 Replies

9. UNIX for Dummies Questions & Answers

find Search - Find files not matching a pattern

Hello all, this is my first and probably not my last question around here. I do hope you can help or at least point me in the right direction. My question is as follows, I need to find files and possible folders which are not owner = AAA group = BBB with a said location and all sub folders ... (7 Replies)
Discussion started by: kilobyter
7 Replies

10. Shell Programming and Scripting

Search for text in files

I am working on a script to search for text. read -p "Enter text to search for : " n1 grep $n1 /home/andy/bin/*.sh It works, but if I backspace, it does this. Enter text to search for : sset Master^ ------ Post updated at 12:39 PM ------ My mistake is I used the left arrow key... (4 Replies)
Discussion started by: drew77
4 Replies
Pod::Simple::HTML(3)					User Contributed Perl Documentation				      Pod::Simple::HTML(3)

NAME
Pod::Simple::HTML - convert Pod to HTML SYNOPSIS
perl -MPod::Simple::HTML -e Pod::Simple::HTML::go thingy.pod DESCRIPTION
This class is for making an HTML rendering of a Pod document. This is a subclass of Pod::Simple::PullParser and inherits all its methods (and options). Note that if you want to do a batch conversion of a lot of Pod documents to HTML, you should see the module Pod::Simple::HTMLBatch. CALLING FROM THE COMMAND LINE
TODO perl -MPod::Simple::HTML -e Pod::Simple::HTML::go Thing.pod Thing.html CALLING FROM PERL
Minimal code use Pod::Simple::HTML; my $p = Pod::Simple::HTML->new; $p->output_string(my $html); $p->parse_file('path/to/Module/Name.pm'); open my $out, '>', 'out.html' or die "Cannot open 'out.html': $! "; print $out $html; More detailed example use Pod::Simple::HTML; Set the content type: $Pod::Simple::HTML::Content_decl = q{<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >}; my $p = Pod::Simple::HTML->new; Include a single javascript source: $p->html_javascript('http://abc.com/a.js'); Or insert multiple javascript source in the header (or for that matter include anything, thought this is not recommended) $p->html_javascript(' <script type="text/javascript" src="http://abc.com/b.js"></script> <script type="text/javascript" src="http://abc.com/c.js"></script>'); Include a single css source in the header: $p->html_css('/style.css'); or insert multiple css sources: $p->html_css(' <link rel="stylesheet" type="text/css" title="pod_stylesheet" href="http://remote.server.com/jquery.css"> <link rel="stylesheet" type="text/css" title="pod_stylesheet" href="/style.css">'); Tell the parser where should the output go. In this case it will be placed in the $html variable: my $html; $p->output_string($html); Parse and process a file with pod in it: $p->parse_file('path/to/Module/Name.pm'); METHODS
TODO all (most?) accessorized methods The following variables need to be set before the call to the ->new constructor. Set the string that is included before the opening <html> tag: $Pod::Simple::HTML::Doctype_decl = qq{<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> }; Set the content-type in the HTML head: (defaults to ISO-8859-1) $Pod::Simple::HTML::Content_decl = q{<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >}; Set the value that will be ebedded in the opening tags of F, C tags and verbatim text. F maps to <em>, C maps to <code>, Verbatim text maps to <pre> (Computerese defaults to "") $Pod::Simple::HTML::Computerese = ' class="some_class_name'; html_css html_javascript title_prefix title_postfix html_header_before_title This includes everything before the <title> opening tag including the Document type and including the opening <title> tag. The following call will set it to be a simple HTML file: $p->html_header_before_title('<html><head><title>'); html_h_level Normally =head1 will become <h1>, =head2 will become <h2> etc. Using the html_h_level method will change these levels setting the h level of =head1 tags: $p->html_h_level(3); Will make sure that =head1 will become <h3> and =head2 will become <h4> etc... index Set it to some true value if you want to have an index (in reality a table of contents) to be added at the top of the generated HTML. $p->index(1); html_header_after_title Includes the closing tag of </title> and through the rest of the head till the opening of the body $p->html_header_after_title('</title>...</head><body id="my_id">'); html_footer The very end of the document: $p->html_footer( qq[ <!-- end doc --> </body></html> ] ); SUBCLASSING
Can use any of the methods described above but for further customization one needs to override some of the methods: package My::Pod; use strict; use warnings; use base 'Pod::Simple::HTML'; # needs to return a URL string such # http://some.other.com/page.html # #anchor_in_the_same_file # /internal/ref.html sub do_pod_link { # My::Pod object and Pod::Simple::PullParserStartToken object my ($self, $link) = @_; say $link->tagname; # will be L for links say $link->attr('to'); # say $link->attr('type'); # will be 'pod' always say $link->attr('section'); # Links local to our web site if ($link->tagname eq 'L' and $link->attr('type') eq 'pod') { my $to = $link->attr('to'); if ($to =~ /^Padre::/) { $to =~ s{::}{/}g; return "/docs/Padre/$to.html"; } } # all other links are generated by the parent class my $ret = $self->SUPER::do_pod_link($link); return $ret; } 1; Meanwhile in script.pl: use My::Pod; my $p = My::Pod->new; my $html; $p->output_string($html); $p->parse_file('path/to/Module/Name.pm'); open my $out, '>', 'out.html' or die; print $out $html; TODO maybe override do_beginning do_end SEE ALSO
Pod::Simple, Pod::Simple::HTMLBatch TODO: a corpus of sample Pod input and HTML output? Or common idioms? SUPPORT
Questions or discussion about POD and Pod::Simple should be sent to the pod-people@perl.org mail list. Send an empty email to pod-people-subscribe@perl.org to subscribe. This module is managed in an open GitHub repository, <https://github.com/theory/pod-simple/>. Feel free to fork and contribute, or to clone <git://github.com/theory/pod-simple.git> and send patches! Patches against Pod::Simple are welcome. Please send bug reports to <bug-pod-simple@rt.cpan.org>. COPYRIGHT AND DISCLAIMERS
Copyright (c) 2002-2004 Sean M. Burke. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. ACKNOWLEDGEMENTS
Thanks to Hurricane Electric <http://he.net/> for permission to use its Linux man pages online <http://man.he.net/> site for man page links. Thanks to search.cpan.org <http://search.cpan.org/> for permission to use the site for Perl module links. AUTHOR
Pod::Simple was created by Sean M. Burke <sburke@cpan.org>. But don't bother him, he's retired. Pod::Simple is maintained by: o Allison Randal "allison@perl.org" o Hans Dieter Pearcey "hdp@cpan.org" o David E. Wheeler "dwheeler@cpan.org" perl v5.16.3 2013-05-03 Pod::Simple::HTML(3)
All times are GMT -4. The time now is 06:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy