Skip to content
Advertisement

Tag: find

grep without showing path/file:line

How do you grep and only return the matching line? i.e. The path/filename is omitted from the results. In this case I want to look in all .bar files in the current directory, searching for the term FOO Answer No need to find. If you are just looking for a pattern within a specific directory, this should suffice: Where -h

List all graphic image files with find? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question

Print md5sum of results of a find command in Linux

I am tryng to do checksum on all .jar files I can find in directory and its sub directories. Then print the filename with the checksum value to a file. this is what I have. I am trying to join two commands together that I know work individually. Any help appreciated. Answer You could use something like this to execute

Grep inside all files created within date range

I am on the Ubuntu OS. I want to grep a word (say XYZ) inside all log files which are created within date range 28-may-2012 to 30-may-2012. How do I do that? Answer This is a little different from Banthar’s solution, but it will work with versions of find that don’t support -newermt and it shows how to use the

regular expression to exclude filetypes from find

When using find command in linux, one can add a -regex flag that uses emacs regualr expressions to match. I want find to look for all files except .jar files and .ear files. what would be the regular expression in this case? Thanks Answer You don’t need a regex here. You can use find with the -name and -not options:

linux find regex

I’m having trouble using the regex of the find command. Probably something I don’t understand about escaping on the command line. Why are these not the same? Bash, Ubuntu Answer Regular expressions with character classes (e.g. [[:digit:]]) are not supported in the default regular expression syntax used by find. You need to specify a different regex type such as posix-extended

How to find directories with the name of specific length

How could I find directories with the name of specific length? For example, I have bunch of directories which have length of the name equal to 33 chars (‘a92e8cc611fdebcca3cf2fc8dc02c918’, ‘c442fb3f46d6c8bd17d27245290a9512’ and so on). Does find utility accepts condition in form of the ‘wc -c’? Or maybe some other utilities should be piped together? Answer few ways with GNU find

How can I search for a multiline pattern in a file?

I needed to find all the files that contained a specific string pattern. The first solution that comes to mind is using find piped with xargs grep: But if I need to find patterns that spans on more than one line, I’m stuck because vanilla grep can’t find multiline patterns. Answer So I discovered pcregrep which stands for Perl Compatible

Advertisement