Maybe unpopular take, but cat foo | grep is better than grep, because it has a cat in it. Cats are cute!

#Linux #grep #linux_terminal #Cats #AppropriateUseOfCat

Wusstet ihr, dass `grep` seinen Namen von einem `ed`-Befehl hat? `g/re/p` = "global / regular expression / print". Also buchstäblich ein Akronym aus nem Texteditor-Kommando aus den 70ern. 🐧

Linux ist manchmal wie ein archäologisches Ausgrabungsfeld – aber die alten Sachen funktionieren noch. Und das ist eigentlich ziemlich cool.

#Linux #grep #Unix #FreieSoftware #Terminal

Wusstet ihr, dass `grep -r "fehler" .` euer gesamtes Projektverzeichnis nach dem Wort "fehler" durchsucht? Klingt banal, bis man um 2 Uhr nachts verzweifelt diesen einen Tippfehler sucht, der den Build zerschossen hat. 🔍

Spoiler: Es war natürlich in der Datei, die man zuletzt angeschaut hätte.

#Linux #grep #CLI #FreieSoftware #Debugging

Just thought of a reason why you'd want to use soft #wrapping and not hard wrapping (in your #editor, #git #commit messages, etc): if you #grep for a phrase, it won't match instances where there's a hard #wrap in the middle of the phrase.

#programming

@ai6yr Well THERE is your problem.

You have a #gripe and you should have a #grep

😎

A #grep a day keeps the #spyware away.
🗃️ ARCHIVE : « Comment j'ai (presque) foutu en l'air une demi-journée de boulot » (2023)
Récupérer un fichier texte perdu avec un bête « grep », c'est la magie de Gnunux…
▶️ https://studios.ptilouk.net/superflu-riteurnz/blog/2023-02-09_recovery.html
#BD #GriseBouille #humour #grep #script #GNULinux #Linux

@gumnos

A subtler version of another part of the bug is caused by a similarly bad handling of EOF in another part of #FreeBSD #grep's roll-its-own I/O library.

https://cgit.freebsd.org/src/tree/usr.bin/grep/file.c#n139

With your example of

/usr/bin/grep x

You can enter a single space, then terminate the read(2) with the EOF special character; and you'll have to send EOF 2 more times to get grep to exit.

A regular file containing just a SPC exhibits the same behaviour of wrongly needing to receive EOF from read() twice.

file.c « grep « usr.bin - src - FreeBSD source tree

@gumnos

Here's part of the bug.

https://github.com/freebsd/freebsd-src/blob/main/usr.bin/grep/file.c#L210

There's no handling of EOF if it occurs as the very first read() of the file.

A zero-length regular file and /dev/null will also result in two read()s returning 0 before grep then exits.

This code was introduced in commit 3ed1008b891eb34df96a6ae4f87e5a3270be759c in 2010.

#OpenBSD's version of this code is older and uses the normal C stdio library routines and getline(3) rather than rolling its own layer over read().

#FreeBSD #grep

freebsd-src/usr.bin/grep/file.c at main · freebsd/freebsd-src

The FreeBSD src tree publish-only repository. Experimenting with 'simple' pull requests.... - freebsd/freebsd-src

GitHub

#TerminalTip: how to use #grep to highlight a line of interest to you without removing any other lines:

Let's say you're using a command that lists something, and you want to highlight any line that contains the word "apple", without highlighting anything else, or removing any lines from the output. Here's how you can do that:

some_command |grep --color -ie ^ -e "^.*apple.*$"