Tag Info

New answers tagged

1

You can write a search provider — see this documentation. But that won't change the application search. The default search is built-in, and it orders applications by frequency, which, from this source file, we can see is stored in ~/.local/share/gnome-shell/application_state. From the source, the algorithm is: /* The ranking algorithm we use is: every time ...


0

Try: $ case "$(head -n 1 < file)" in (*pattern*) echo Match ;; esac Match


0

Do you want the list of full strings as a result, or do you want a list of files that contain the string? This would search line number one(-n1) of shell scripts(*.sh) and collect the strings containing 'bash': head -n1 *.sh | grep bash > fullstring.txt fullstring.txt would contain something like this: #!/bin/bash #!/bin/bash


0

Here is a perl onliner to do just that perl -ne 'print if /MY_SEARCH_STRING/; exit' myfile.txt This is going to check if the keyword MY_SEARCH_STRING is present in the first line of the file myfile.txt. If you need to search in the entire file just remove exit from the oneliner.


0

I have implemented the comment of @Rob and succeeded to get the desired result. Replace string by your string. grep -Rin "string" . | grep ":1:.*string" > result.txt This does a recursive case-insensitive search for string in the current directory and prints the line numbers. Then it searches for occurrences in files which are on line 1 and saves the ...


0

Here is a (bad) example of a perl-script that would do something like this: #!/usr/bin/perl -w foreach (@ARGV) { my $filename = $_; open my $file, '<', $filename; my $line = <$file>; close $file; print "$filename\n" if $line =~ /your-match-text/; }


0

You can use locate command and if you want update its database run the following command: # updatedb This command update the locate database in a few seconds


0

I found following command that will help me: sed '/DIFFERENTIAL/!s/true/false/g'


2

You can try sed: sed -i '3s/true/false/' file.txt If you want to keep the original file as file.txt.bak: sed -i.bak '3s/true/false/' file.txt Also if you want to replace more than one occurrence of true with false in the same line: sed -i.bak '3s/true/false/g' file.txt EDIT: As per your clarified query, Try this: sed -i.bak ...


2

The most straightforward solution is to upgrade to less 441 or newer. From the changelog: less-440 fixes a bug in less-438 and, at the risk of some feature creep, adds one much requested feature. The -A option changes search behavior so that an initial search includes the entire displayed screen and does not skip the first line as is currently done. ...


1

The best workaround I could come up with is using the "KEEP current position" feature to highlight the matched text but do not jump to target line: /CTRL+Kpattern However, it incurs additional keystrokes. edit: The issue has been fixed in newer version of less. Refer to @Gilles's answer for details.


1

There's a lot of confusion here because there isn't just one zgrep. I have two versions on my system, zgrep from gzip and zgrep from zutils. The former is just a wrapper script that calls gzip -cdfq. It doesn't support the -r, --recursive switch.1 The latter is a c++ program and it supports the -r, --recursive option. Running zgrep --version | head -n 1 will ...


0

ag is a variant of grep, with some nice extra features. has -z option for compressed files, has many of ack features. it is fast So: ag -r -z your-pattern-goes-here folder If not installed, apt-get install silversearcher-ag (debian and friends) yum install the_silver_searcher (fedora) brew install the_silver_searcher (mac)


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 ' \;


4

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 alone 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



Top 50 recent answers are included