I was thinking of grep pun, I couldn't find it.
👍︎ 13
💬︎
📅︎ Dec 30 2018
🚨︎ report
Full storm etter Dagsrevyen-grep: - Som en søknad for Jens Stoltenberg nettavisen.no/okonomi/ful…
👍︎ 140
💬︎
📅︎ Jan 13 2022
🚨︎ report
Flere er kritiske til myndighetenes grep: Hvor mye skal ofres for å skjerme dem som ikke vil vaksinere seg? aftenposten.no/norge/i/oW…
👍︎ 60
💬︎
👤︎ u/Lindberg47
📅︎ Dec 15 2021
🚨︎ report
Grep all files and not directories

Sorry for this trivial question, but I’m learning much about grep currently and I have some questions overflowing that I should get off my mind.

grep -l str * executes grep on all files in the current directory, including directories.

What are some good ways to have it skip directories, since it can’t operate on them and returns an error for them?

Preferably with just Bash operators similar to Zsh’s glob operator: *(.).

Thanks very much

👍︎ 13
💬︎
👤︎ u/jssmith42
📅︎ Jan 14 2022
🚨︎ report
Telescope: FZF + ag for live_grep?

Has anyone figured out how to get the live_grep function of telescope.nvim to behave similarly to :Ag from fzf.vim?

I already have nvim-telescope/telescope-fzf-native.nvim installed and fzf works fine for find_files & grep_string (too slow compared to live_grep). But for some reason, this doesn't apply for live_grep.

If anyone has any ideas, this would be a huge gamechanger since it's pretty much the only thing keeping fzf.vim in my plugins. Thanks!!

👍︎ 23
💬︎
👤︎ u/ledesmablt
📅︎ Jan 17 2022
🚨︎ report
Looking for help with a GREP search.

I’m working on a book where the person before me was using manual hyphens to break up a word so the sentence fit better on the line. I’m looking for a GREP search to find all hyphens at the end of a line. When I search for just a hyphen it’s showing ALL the hyphenated words like dates and names.

👍︎ 4
💬︎
📅︎ Jan 13 2022
🚨︎ report
Analyse: Syv av ti får høyere nettleie hvis de ikke tar grep vg.no/nyheter/innenriks/i…
👍︎ 60
💬︎
👤︎ u/Isolasjon
📅︎ Dec 16 2021
🚨︎ report
Finding a C function declaration with grep

I am trying the following:

grep -r function_name[^;]*{

it keeps matching the function calls though like this:

function_name();

why is it matching lines without the curly brace?

how should I modify this to match declarations that spans multiple lines?

Please let me know if my question is not clear.

👍︎ 12
💬︎
👤︎ u/roboman6
📅︎ Jan 19 2022
🚨︎ report
cat file.txt | grep "asdf"
👍︎ 850
💬︎
📅︎ Nov 13 2021
🚨︎ report
How to use grep to search for 1 or more variables in a case statement?

Hi, I have a list of hundreds of lines, and each line has keywords. I'm actually using this function to match 1 or 2 words that will show two groups of lines for each of the two words:

case $2 in
    *) for var in $2;
    do grep -i -E $2 /file.txt
done
esac

But I want to write "foo bar" and read all the lines containing both "foo" and "bar", I've tried to do so:

case "$2 $3" in
    *) for var in "($2 $3)";
    do grep -i -E "($2 $3)" /file.txt
done
esac

I get an endless output of lines containing also the word " " (ie "space"). I'm several hours I'm trying to solve this issue, also using "cat", "awk" or other commands, without success.

Can you help me please?

👍︎ 9
💬︎
👤︎ u/am-ivan
📅︎ Jan 08 2022
🚨︎ report
Multiline/Following lines grep

How can I easily find all lines containing one string followed by another line containing another string? I can use fugitives `:Ggrep` to do this for single lines and get the result into the quickfix list, but how do I do it for the multiline case?

It would be awesome if there existed a command that was as convenient as this fictional example: `:Ggrepmulti "A" "B"`

👍︎ 2
💬︎
👤︎ u/kaddkaka
📅︎ Jan 13 2022
🚨︎ report
cat comments.txt | grep -i "contrary opinions" > /dev/null
👍︎ 53
💬︎
📅︎ Dec 15 2021
🚨︎ report
Day 8 - The infamous "grep" and other text processors

INTRO

Your server is now running two services: the sshd (Secure Shell Daemon) service that you use to login; and the Apache2 web server. Both of these services are generating logs as you and others access your server - and these are text files which we can analyse using some simple tools.

Plain text files are a key part of "the Unix way" and there are many small "tools" to allow you to easily edit, sort, search and otherwise manipulate them. Today we’ll use grep, cat, more, less, cut, awk and tail to slice and dice your logs.

The grep command is famous for being extremely powerful and handy, but also because its "nerdy" name is typical of Unix/Linux conventions.

TASKS

  • Dump out the complete contents of a file with cat like this: cat /var/log/apache2/access.log
  • Use less to open the same file, like this: less /var/log/apache2/access.log - and move up and down through the file with your arrow keys, then use “q” to quit.
  • Again using less, look at a file, but practice confidently moving around using gg, GG and /, n and N (to go to the top of the file, bottom of the file, to search for something and to hop to the next "hit" or back to the previous one)
  • View recent logins and sudo usage by viewing /var/log/auth.log with less
  • Look at just the tail end of the file with tail /var/log/apache2/access.log (yes, there's also a head command!)
  • Follow a log in real-time with: tail -f /var/log/apache2/access.log (while accessing your server’s web page in a browser)
  • You can take the output of one command and "pipe" it in as the input to another by using the | (pipe) symbol
  • So, dump out a file with cat, but pipe that output to grep with a search term - like this: cat /var/log/auth.log | grep "authenticating"
  • Simplify this to: grep "authenticating" /var/log/auth.log
  • Piping allows you to narrow your search, e.g. grep "authenticating" /var/log/auth.log | grep "root"
  • Use the cut command to select out most interesting portions of each line by specifying "-d" (delimiter) and "-f" (field) - like: grep "authenticating" /var/log/auth.log| grep "root"| cut -f 10- -d" " (field 10 onwards, where the delimiter between field is the " " character). This approach can be very useful in extracting useful information from log
... keep reading on reddit ➡

👍︎ 12
💬︎
👤︎ u/livia2lima
📅︎ Jan 11 2022
🚨︎ report
top | grep process, then kill the pid from one command?

Every now and again I have to kill a misbehaving app. How can I do so with one command?

👍︎ 25
💬︎
📅︎ Dec 06 2021
🚨︎ report
find with multiple grep

I have file1.txt:

cat file1.txt 
red 1
red 2
1

and file2.txt:

cat file2.txt 
red 3
red 4
4

I'm looking to find all txt files that contains either red 1 or red 4. This is what I tried but don't get the expected result:

find . -name '*.txt' -exec grep -q red {} \; -exec grep -E '1|4' {} \;
red 4
4
red 1
1

It looks like it is the same as doing the second grep only i.e.

find . -name '*.txt' -exec grep -E '1|4' {} \;

red 4

4

red 1

1

What am I missing?

👍︎ 3
💬︎
📅︎ Jan 05 2022
🚨︎ report
...# find /var/log -iname "*.log" -exec grep -rm -rf "audit", "auth", "secure", "sudo" {} \;
👍︎ 17k
💬︎
📅︎ Aug 16 2021
🚨︎ report
cat ~/.bash_history | grep clear
👍︎ 97
💬︎
📅︎ Nov 14 2021
🚨︎ report
Tromsø med nytt Qatar-grep: Spiller i «QR-drakt» vg.no/i/v58gkj
👍︎ 55
💬︎
👤︎ u/Skogsmann1
📅︎ Dec 06 2021
🚨︎ report
Subprocess doesn’t seem to execute grep command the same

I can confirm that “grep -l -d skip word *” returns a list of files in my local directory (skipping subdirectories) which contain the string “word” in them.

However, I called this from subprocess in the following way:

>>> import subprocess; subprocess.run(args=[“grep”, “-ld”, “skip”, “a”, “*”])

and received the error “*: No such file or directory”.

It works if I pass the string as a single string with the option shell=True.

Is there something wrong with how the * operator is being passed?

Thank you

👍︎ 8
💬︎
👤︎ u/jssmith42
📅︎ Jan 14 2022
🚨︎ report
Buffer made up from grep results ("gather/scatter") ?

I stumbled on a certain feature some time ago, and completely forgot where I found it.

But I remember what it does:

  1. find every occurrence of some regex, say "printf," recursively in a directory tree (call this the "gather" step)
  2. populate a buffer with every line matching that regex; edit in that buffer as if it were a file
  3. on "save," have every modified line "scattered" back out to its original file

Anyone kind enough to point out a package that does this or something close to it?

👍︎ 14
💬︎
👤︎ u/rebcabin-r
📅︎ Dec 26 2021
🚨︎ report
pre-pkg_03-rewrite-python-shebang: 'grep -o '[[:digit:]]\.[[:digit:]]\+$'' exited with 1

template here,
errors:

=> grapejuice-4.8.2_1: running pre-pkg hook: 03-rewrite-python-shebang ...
=> ERROR: grapejuice-4.8.2_1: pre-pkg_03-rewrite-python-shebang: 'grep -o '[[:digit:]]\.[[:digit:]]\+$'' exited with 1
=> ERROR:   in hook() at common/hooks/pre-pkg/03-rewrite-python-shebang.sh:8
=> ERROR:   in run_func() at common/xbps-src/shutils/common.sh:21
=> ERROR:   in run_pkg_hooks() at common/xbps-src/shutils/common.sh:245
=> ERROR:   in main() at common/xbps-src/libexec/xbps-src-prepkg.sh:47
=> ERROR: grapejuice-4.8.2_1: pre-pkg_03-rewrite-python-shebang: 'pyver="$(find ${PKGDESTDIR}/usr/lib/python* -prune -type d | grep -o '[[:digit:]]\.[[:digit:]]\+$')"' exited with 1
=> ERROR:   in hook() at common/hooks/pre-pkg/03-rewrite-python-shebang.sh:8
=> ERROR:   in run_func() at common/xbps-src/shutils/common.sh:21
=> ERROR:   in run_pkg_hooks() at common/xbps-src/shutils/common.sh:245
=> ERROR:   in main() at common/xbps-src/libexec/xbps-src-prepkg.sh:47

yes my template is absolutely shit. i don't know what i'm doing and i'm just copying the AUR PKGBUILD, please criticize

👍︎ 2
💬︎
👤︎ u/wael444
📅︎ Jan 10 2022
🚨︎ report
Specify list of directories to fuzzy "find files"/grep in

Hey, currently when working on a large codebase containing multiple repositories I use :cd to set the directory for finding files/grepping. This drastically reduces the search space, but isn't a very good flow when having to :cd between 6 or 7 different directories often.

I'm looking for a way to specify a list of directories on which grep and file find will be applied. The use case for this is similar to the don't grep/find stuff defined in .gitignore, just usable with codebases containing multiple git repos.

There are two merged telescope PRs somewhat touching the subject:

For fzf there is a workaround to specify the dirs in an ENV variable.

UPDATE

Looking at telescope help (:h telescope) it shows that both find_files and live_grep both have search_dirs as an argument. Need to do a PoC with this. Am lacking Lua knowledge to pass a list of dirs to the function call from nvim.

Attempt
:lua require("telescope.builtin").find_files( <List of dirs> )

Does anyone know a flow which would cover this?

👍︎ 2
💬︎
📅︎ Jan 04 2022
🚨︎ report
GREP TO FIND AND CHANGE AFTER A NUMBER /P

Is there a grep to find and change after a number imput a force line break?

I have some like this

"1651651 John Doe"

The number is variable , and the name too.

I want to do that

"1651651

John Doe"

👍︎ 3
💬︎
👤︎ u/BotaFurada
📅︎ Jan 05 2022
🚨︎ report
GNU grep Windows64bitネィテイブ版のリビルド

Gnu grep for windows

GNU grepのWindows64bitネィティブ版は、コマンドラインのワイルドカードを展開しない問題があってリビルドしないといけない。

修正してリビルドしたものはこちら

--修正の手順は以下の通り--

提供されているpatchファイルはインクルードパスをフルパスで書いてある場所があり(⌒_⌒; )、 事前に自前環境に合わせて直すか、 またはビルドの過程でパスを変換するスクリプトを通す手当が必要になる。

例(patchの中身):

+# include "E:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.30.30705\include\limits.h"
+#include "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\ucrt\ctype.h"

patchはLinux上で当てる。 ソースツリーのファイルの中身には英語でも日本語でもない文字が含まれているので、 Windows版のツールが正常に動作するかどうかあやしい。

まず、grep-3.7.tar.xzを展開してから そのツリーのトップ(READMEなどがある場所)へpatchファイルを入れて実行する。

$ patch -Np1 -i grep-3.7-build-VS22-x64.patch

この後、ソースツリーをWindowsへ移し替えて 同梱されているバッチファイルのmake.batを実行する(⌒_⌒; )

A>make.bat

こうするとgrep.exeが出来上がる。 ただ、このままでは引数にワイルドーカードが使えないので、 バッチファイルの末尾のLINKの部分に setargv.objを追加する。

link /LTCG /nologo .\libgreputils.a /OUT:grep.exe 
 .\src\dfasearch.obj .\src\grep.obj .\src\kwsearch.obj 
 .\src\kwset.obj .\src\searchutils.obj setargv.obj

また、ランタイム不要の単体実行ファイルにするには、 バッチファイル中の"cl"を"cl /MT"に置き換える。

:%s/^cl/cl \/MT/

make clean に該当するコンパイルの後始末は以下のようなバッチファイルで行う。

PUSHD LIB
FOR /R %%F IN (*.obj) DO DEL /F %%F
POPD
PUSHD SRC
FOR /R %%F IN (*.obj) DO DEL /F %%F
POPD
DEL /F *.exe

ちなみに、パッチによって埋め込まれたフルパスを自分の環境の環境変数INCLUDEを参照することで自動的に自前コンパイル可能な状態に修正するRubyスクリプトは以下の通り。これをソースツリートップの下のlibの下に保存して実行する。

#coding: cp932

require 'find'

incs = ENV['INCLUDE'].split(';')#.map { |inc| inc.gsub('\\', '/') }

Find.find('.') { |path|
  if File.file?(path) then
    if File.extname(path) =~ /\.[ch]$/ then
      txt = open(path).read
      txt.force_encoding(Encoding::ASCII_8BIT)
      txt = txt.chomp.split(/\n/)
      modified = nil
      txt.each_index { |n|
        if m = /^(\s*[#]\s*include\s+["<])([^>"]+)([>"].*)$/.match(txt[n]) then
          if txt[n] =~ /Program Files/i then
            bname = File.basename(m[2])
            tname = nil
            incs.each { |inc| 
              if File.exist?("#{inc}\\#{bname}") then
                tname = "#{inc}\\#{bname}"
                txt[n] = m[1] + tname + m[3]
                puts "MODIFY:#{txt[n]}"
                modified = true;
                break
              end
            }
          end
... keep reading on reddit ➡

👍︎ 6
💬︎
📅︎ Jan 09 2022
🚨︎ report
Finding character after certain string with grep

I need to find letters A-Z and spaces only one character after "7@9a" in a .txt file. So far I've managed to put up this: grep -oPa "(?<=[7@9a])[A-Z]" file.txt, but this returns characters after every single one of the "keys" and not after a string. What do I need to change?

Example: nn147@9aAxyyy --> has to return A

👍︎ 11
💬︎
👤︎ u/DJCrabo
📅︎ Dec 22 2021
🚨︎ report
cat ~/.bash_history | grep clear
👍︎ 83
💬︎
📅︎ Nov 14 2021
🚨︎ report
grep using regex not returning a result

Ive tested this regular expression on regexr.com and I get a match however it doesn't seem to be working within a grep

I have alert.txt which I am looking to grep using the following

grep 'Disk drive [/\w]+ is at \d+% full

However the grep doesn't return anything.

I'm assuming it's because grep doesn't have this functionality. Is there a better way of doing this compatible with a grep command.

👍︎ 4
💬︎
👤︎ u/hitmanjd
📅︎ Dec 21 2021
🚨︎ report
Grep matching brackets

Hi,

I have a file from which I need to extract matching brackets, but I cannot find the right way to do it.

Here is my file content :

@article{entry1,
  author       = {author1, author2, etc},
  year         = {2021},
  month        = {01},
  pages        = {},
  title        = {Title here},
  volume       = {15},
  isbn         = {000-0-00000-000-0},
  journal      = {Some journal},
  doi          = {11.1111/1.1111-111}
}

@article{entry2,
  author       = {author3, author4, etc},
  year         = {2000},
  month        = {01},
  pages        = {},
  title        = {Title of the second entry},
  volume       = {1},
  isbn         = {333-3-33333-333-3},
  journal      = {Some other journal},
  doi          = {44.4444/4.4444-444}
}

And I need to match the following pattern : the @ symbol, then letters, then an opening bracket, the "entry1", and everything up to the closing bracket I would expect something like this : @[A-Za-z]{entry1(then something to go to the matching bracket)

The output of the grep search should look like this :

@article{entry1,
  author       = {author1, author2, etc},
  year         = {2021},
  month        = {01},
  pages        = {},
  title        = {Title here},
  volume       = {15},
  isbn         = {000-0-00000-000-0},
  journal      = {Some journal},
  doi          = {11.1111/1.1111-111}
}

I found this post (https://unix.stackexchange.com/questions/147662/grep-upto-matching-brackets) but I cannot adapt it to have the "entry1" inside of the matching brackets.

Could you please help me ?

Thank you

👍︎ 8
💬︎
👤︎ u/manu0600
📅︎ Dec 22 2021
🚨︎ report
En påminnelse om hva som må til for å holde global oppvarming under 1.5 grader. Hadde verden tatt grep i 1990 hadde vi hatt 100 år. Nå har vi rundt 20. Virker umulig.
👍︎ 456
💬︎
📅︎ Aug 27 2021
🚨︎ report
Man som greps av Säpo är toppchef på myndighet omni.se/man-som-greps-av-…
👍︎ 204
💬︎
👤︎ u/drakoxe
📅︎ Sep 23 2021
🚨︎ report
less /nature | grep human [ Canon 300V, 35-105mm, f/4.5, Fomapan 200 ] reddit.com/gallery/s45yn1
👍︎ 5
💬︎
👤︎ u/35mm_Noob
📅︎ Jan 14 2022
🚨︎ report
Grep for strings in binary git data on a git server to find vulnerable log4j projects

Hello,

we're hosting Git repos with Bitbucket. Regarding to Log4Shell, I'd like to search for log4j in those repos. My idea is to generate a list of all affected repos so that our developers can also check their version on the internal projects.

The data directory contains a subfolder shared/data/repositories with all the binary repo data. Each repo contains files like HEAD, config, repository-config and the folders hooks,objects,refs. Since Git uses a binary format, I cannot simply grep for log4j over those files. So I tried to use git grep, but it doesn't seem to work too:

/opt/bitbucket_data/shared/data/repositories/999 # git grep --all-match log4j
fatal: Couldn't JIT the PCRE2 pattern 'log4j', got '-48'

Am I using it wrong? Is there another way how I could search through the binary git data in all of the repos on the server?

👍︎ 10
💬︎
👤︎ u/Th3Dan_
📅︎ Dec 14 2021
🚨︎ report
How can I search current word under cursor in :Telescope grep_string?

Is there any keymap for telescope so that I can press that when my cursor is over some word and search that in :Telescope grep_string or if there is something similar to ctrl-r ctrl-w in command line mode to get the current word over cursor.

👍︎ 5
💬︎
📅︎ Dec 11 2021
🚨︎ report
Trying to check that my participation node is participating for the first time after setup. Not seeing a return from the command "grep 'VoteBroadcast' node.log" Did I do something wrong?

Hello,

I have managed to successfully get to the final step in setting up my Algorand node following this guide:

https://developer.algorand.org/docs/run-a-node/participate/online/

At the step: Run a node>Participate in consensus>Register online>Check that the node is participating

I am running the command: "grep 'VoteBroadcast' node.log" in the data directory.

The command is going through successfully without errors but it's not returning any output like in the example. Does this mean I did something wrong?

👍︎ 7
💬︎
📅︎ Dec 03 2021
🚨︎ report
Lade elbil på Tesla Supercharger: - Tesla tar grep - vil åpne ladenettverket i Norge elbil24.no/nyheter/tesla-…
👍︎ 4
💬︎
👤︎ u/Ok-Curves
📅︎ Dec 04 2021
🚨︎ report
How to live_grep in telescope on certain folders on demand

Hi all,

Depending on the project, I often want to start my live_grep search in a particular folder (e.g: only search in main and not in test ). I know that I can set a configuration to ignore/exclude certain folders in telescope or set a flag for rg. However, the folder which should be ignored changes frequently. Therefore I'm looking for a solution where I can set the ignored folder on demand. I could create a .rgignore and change it depending on my search but this seems quite cumbersome.

Do you guys and girls know any way to exclude files directly from the telescope prompt or have and other ideas to achieve this?

Thanks!

👍︎ 11
💬︎
📅︎ Dec 02 2021
🚨︎ report
Day 8 - The infamous "grep" and other text processors

INTRO

Your server is now running two services: the sshd (Secure Shell Daemon) service that you use to login; and the Apache2 web server. Both of these services are generating logs as you and others access your server - and these are text files which we can analyse using some simple tools.

Plain text files are a key part of "the Unix way" and there are many small "tools" to allow you to easily edit, sort, search and otherwise manipulate them. Today we’ll use grep, cat, more, less, cut, awk and tail to slice and dice your logs.

The grep command is famous for being extremely powerful and handy, but also because its "nerdy" name is typical of Unix/Linux conventions.

TASKS

  • Dump out the complete contents of a file with cat like this: cat /var/log/apache2/access.log
  • Use less to open the same file, like this: less /var/log/apache2/access.log - and move up and down through the file with your arrow keys, then use “q” to quit.
  • Again using less, look at a file, but practice confidently moving around using gg, GG and /, n and N (to go to the top of the file, bottom of the file, to search for something and to hop to the next "hit" or back to the previous one)
  • View recent logins and sudo usage by viewing /var/log/auth.log with less
  • Look at just the tail end of the file with tail /var/log/apache2/access.log (yes, there's also a head command!)
  • Follow a log in real-time with: tail -f /var/log/apache2/access.log (while accessing your server’s web page in a browser)
  • You can take the output of one command and "pipe" it in as the input to another by using the | (pipe) symbol
  • So, dump out a file with cat, but pipe that output to grep with a search term - like this: cat /var/log/auth.log | grep "authenticating"
  • Simplify this to: grep "authenticating" /var/log/auth.log
  • Piping allows you to narrow your search, e.g. grep "authenticating" /var/log/auth.log | grep "root"
  • Use the cut command to select out most interesting portions of each line by specifying "-d" (delimiter) and "-f" (field) - like: grep "authenticating" /var/log/auth.log| grep "root"| cut -f 10- -d" " (field 10 onwards, where the delimiter between field is the " " character). This approach can be very useful in extracting useful information from log
... keep reading on reddit ➡

👍︎ 28
💬︎
👤︎ u/livia2lima
📅︎ Dec 14 2021
🚨︎ report
Telescope live_grep on a single file *only*?

I know how to call Telescope for a particular directory, e.g.

Telescope live_grep cwd=nvim/plugin

but I've not figured out a way yet to call it on a single file.

Can anyone help?

👍︎ 10
💬︎
📅︎ Dec 20 2021
🚨︎ report
how to make telescope live_grep support fzf fuzzy

I know this nvim-telescope/telescope-fzf-native.nvim

but live_grep use sorter = sorters.highlighter_only(opts), not change,

is there a way to support it?

👍︎ 10
💬︎
👤︎ u/zdm-red
📅︎ Dec 24 2021
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.