Tag Info

New answers tagged

1

If your system has zgrep, you can simply zgrep -irs your-pattern-goes-here the-folder-to-search-goes-here/ If your system does not have zgrep, you can use the find command to run zcat and grep against each file like so: find the-folder-to-search-goes-here/ -name '*.gz' \ -exec sh -c 'echo "Searching {}" ; zcat "{}" | grep your-pattern-goes-here ' \;


3

If you want to grep recursively in all .eml.gz files, you can use: find -name \*.eml.gz -print0 | xargs -0 zgrep "STRING" You have to escape the first '*' so that the shell does not interpret it. "-print0" tells find to print a null character after each file it finds; "xargs -0" reads from standard input and runs the command after it for each file; ...


2

Recursion is easy: -r, --recursive Read all files under each directory, recursively, following symbolic links only if they are on the command line. This is equivalent to the -d recurse option. -R, --dereference-recursive Read all files under each directory, recursively. Follow all ...


1

You have to use zgrep or if your system doesn't have it: zcat filename | grep string


0

Simply a normal grep which supports Perl-regexp parameter P will do this job. $ echo 'abc blah blah blah def blah blah blah' | grep -oPz '(?s)abc.*?def' abc blah blah blah def (?s) called DOTALL modifier which makes dot in your regex to match not only the characters but also the line breaks.


0

The grep alternative sift supports multiline matching (disclaimer: I am the author). Suppose testfile contains: <book> <title>Lorem Ipsum</title> <description>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</description> </book> sift ...


0

sed "s/\($(printf "[0-9][0-9]%s" '' - - '\) \(' : : '')\)/\1T\2/g" Maybe try building out your pattern programmatically. That can sometimes make it a little easier to nail down the very specific types. The above expands to... sed 's/\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\)/\1T\2/g' (but without the ...


4

Let a.txt be: aaa bbb ccc Let b.txt be: aaa bbb ccc ddd eee Using comm with -3 you can get the desired result: comm -3 a.txt b.txt ddd eee


2

have a look at comm(1). what you are looking for is comm -13 file1 file2 or comm -3 file1 file2


1

you can also use - comm -23 file1 file2 the files have to be sorted for the command to work properly. the entries from file2 will be removed from file1 in the output of the command


2

To have search results highlighted, the option is hlsearch. According to the help it is off by default. So either use :set hlsearch or add it to your .vimrc. The command :nohlsearch turns the highlighting off temporarily, until the next search. To make the cursor position more obvious I also use set cul and set cuc to highlight the current line and ...


0

Where the packages gets installed heavily depends on the system configuration /usr/lib/python<version>/site-packages is a good candidate but doesn't always exists, sometimes this is /usr/lib/python<version>/dist-packages or /usr/local/lib/python<version>/site-packages etc. The generic way if you have found the pithos script is to locate ...


0


3

sed '/\n/P;//!s/_\.[^ ("]*Text([^)]*)/\n&\n/;D' files... >results.txt ...would probably work. Run on your example data it prints: _.Text("Hello World!") _.Text("Foo") _.ActionText("Bar") All it does is attempt to enclose the first match on a line in \newlines. Whether or not it succeeds it Deletes up to the first \newline in pattern space - which ...


2

You can specifiy multiple directories in grep: grep -r "string" app/assets/javascripts spec/javascripts Alternatively - sometimes more useful is list files to grep by find, and then grep them, for example find app/assets/javascripts spec/javascripts -type f -print0 | xargs -0 grep "string" or find app/assets/javascripts spec/javascripts -type f ...



Top 50 recent answers are included