photog.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A place for your photos and banter. Photog first is our motto Please refer to the site rules before posting.

Administered by:

Server stats:

245
active users

#grep

2 posts2 participants0 posts today

#ripgrep replacement in #bash with #GNU #grep.

forgejo.mueller.network/Zenton

ripgrepgeneric: da, wo es kein ripgrep gibt ☝️

zum beispiel auf alten, zu migrierenden, servern. auf denen es wohl noch alte configs zu durchforsten, aber keine attraktive möglichkeit ripgrep nachzuinstallieren, gibt.

da sucht man, in welcher datei das suchwort drinsteht und wenn ja, an welcher stelle.

dieser zweizeiler mit variablenübernahme wird durch das script komftebel™ vertreten.

Summary card of repository Zentonic/ripgrepgeneric
forgejo.mueller.network: Beyond coding. We Forge.ripgrepgenericrgn [PATH] [EXPRESSION] -> ripgrep Ersatz mit GNU grep

You know how you can understand something like Regular Expressions (Grep) well enough to write really complex statements that precisely match the nuanced text patterns you’re hoping to revise, but then 6 months later you look at this RegEx you wrote and can’t parse it at all? Like, literally no idea how it works? As in it-would-be-faster-to-recreate-it-from-scratch-than-to-understand-it-enough-to-change-it-even-slightly?

I feel like that all the time.

I've mirrored a relatively simple website (redsails.org; it's mostly text, some images) for posterity via #wget. However, I also wanted to grab snapshots of any outlinks (of which there are many, as citations/references). By default, I couldn't figure out a configuration where wget would do that out of the box, without endlessly, recursively spidering the whole internet. I ended up making a kind-of poor man's #ArchiveBox instead:

for i in $(cat others.txt) ; do dirname=$(echo "$i" | sha256sum | cut -d' ' -f 1) ; mkdir -p $dirname ; wget --span-hosts --page-requisites --convert-links --backup-converted --adjust-extension --tries=5 --warc-file="$dirname/$dirname" --execute robots=off --wait 1 --waitretry 5 --timeout 60 -o "$dirname/wget-$dirname.log" --directory-prefix="$dirname/" $i ; done

Basically, there's a list of bookmarks^W URLs in others.txt that I grabbed from the initial mirror of the website with some #grep foo. I want to do as good of a mirror/snapshot of each specific URL as I can, without spidering/mirroring endlessly all over. So, I hash the URL, and kick off a specific wget job for it that will span hosts, but only for the purposes of making the specific URL as usable locally/offline as possible. I know from experience that this isn't perfect. But... it'll be good enough for my purposes. I'm also stashing a WARC file. Probably a bit overkill, but I figure it might be nice to have.

Die #InDesigns #GREP-Engine kann im #Lookbehind nur eine fest definierte Anzahl von Zeichen prüfen – nicht eine beliebige Länge.

Wenn man beispielsweise schließende Klammern nur dann finden möchte, wenn davor ein beliebig langer Text steht, geht das nicht.

(?<=\d{3}) (3 Ziffern) funktioniert.
(?<=\d+) (eine oder mehrere Ziffern) funktioniert nicht.

Selbst wenn man Alternativen mit | kombiniert, müssen alle Optionen die gleiche Zeichenzahl aufweisen.

#Lookahead lässt variable Längen zu.

Нечаянно удалил все файлы в папке сайта на сервере. В прошлый раз я потерял очень ценный рабочий скрипт-файл и это было в позапрошлом году. Extundelete и testdisk ни черта не помогли. Не тогда, не в этот раз. Пришлось опять через grep искать по подстроке на всём жёстком диске содержимое файла.

Вот примерная строка запуска, если кому надо:
grep --binary-files=text --context=1350 'SELECT * FROM posts WHERE post_hidden < 2' /dev/sda1 > found_data1

Ext4 конечно плоха в этом плане. ReiserFS 3.6 раньше позволяла почти все удалённые файлы восстановить. Интересно как в этом плане дела обстоят у BtrFS и XFS?

[Archive — 2023] Comment j'ai (presque) foutu en l'air une demi-journée de boulot

Si vous avez viré par erreur un fichier texte, un simple grep peut vous sauver la vie. Une histoire qui commence très mal mais finit très bien grâce à GNU/Linux !

▶️ Lire cet article : studios.ptilouk.net/superflu-r
📗 Le livre best of : editions.ptilouk.net/gb10ans
❤️ Soutien : ptilouk.net/#soutien

#archive #technique #grep #dev #récupération #GNUlinux

studios.ptilouk.net/superflu-r

Superflu Riteurnz BlogComment j'ai (presque) foutu en l'air une demi-journée de boulot
More from Ptilouk.net Studios

@holger grep, awk and sed. Available on pretty much every distribution. Not leaking info, either.

Honestly - steep learning curves but once you're even slightly proficient then you can find all the needles in all the haystacks you want, neatly.

Add in jq for conversion to JSON for a more transportable format.

Replied in thread

@chrys My daily use command line productivity tools are:

1. #readline support. C-a, C-e, C-r and tab-completion will save you h o u r s (M-f, M-b are second-tier here)

2. less and tail

3. #grep

4. #ssh and scp *esp with keys*

5. #bash scripting *on the command line*. that is, writing this in a single line: "while true; do CMD; sleep 1s; done" (more general and less fragile than `watch`)

6. cut and tr (for simple "parse every line of output" situations)

7. #sed and #awk (for hard ones)

How to use the grep command in Linux for searching for, and inside, files

In the vast realm of Linux, an open-source operating system, the grep command holds a significant place. An acronym for ‘Global Regular Expression Print’, the grep command is a widely-used Linux tool that gives users the power to search through text or output ...continues

See gadgeteer.co.za/how-to-use-the

GadgeteerZAHow To Use The Grep Command In Linux For Searching For, And Inside, Files - GadgeteerZAIn the vast realm of Linux, an open-source operating system, the grep command holds a significant place. An acronym for ‘Global Regular Expression Print’, the
#bash#grep#linux