-
Grep code recursively between <script></script> tags
grep -oRP '<script[^>]*>(.*?)</script>'
-
Grep minimum six numbers
grep -E '[0-9]{6}' file.txt
-
Grep files that does not containt string
grep -L "foo" *
-
Find file and grep two values in one grep
find . -name 'myfile' -exec grep 'VAL1\|VAL2' {} ';'
-
Grep two patterns
grep -E 'pattern1.*pattern2' -r
-
Grep a tail output
tail -F file.txt|grep --line-buffered 'stringtogrep'
-
Print only filename
grep -l -R '\[a\]'
-
Grep word after match
grep -oP 'APP_SOCKET_URL=\K.*' .env
-
Grep line after match
grep -A2 "mymatch" myfile.txt
-
Grep 10 lines after match
grep -iR -A 10 'cors:'
-
Grep 5 lines before match
grep -iR -B 10 'cors:'
Last active
November 22, 2023 13:00
-
-
Save vpnwall-services/b5ee5387ada2e031196fdcc5b46207c7 to your computer and use it in GitHub Desktop.
[GREP 101] Grep 101 #grep #101 #find #word #line #after #before #recursive #between #tags #script
Hi,
i found this example => https://stackoverflow.com/questions/7432379/convert-javascript-regexp-to-work-with-grep-or-sed
The main idea is to use egrep (grep -E) for extended Regexp
I hope it fits you needs !
I read that question and answer before asking here. I adjusted the code at https://stackoverflow.com/questions/50666954/switch-puls-audio-record-stream-for-gstreamer-pipeline
SOURCE_OUTPUT_INDEX=`pactl list source-outputs | grep -E "(Source\sOutput|media\.name)" | grep Record\Stream -B1 | grep -o -E -m1 "[0-9]+"`
SOURCE_INDEX=`pactl list sources | grep -E "(Source\s|device\.class)" | grep monitor -B1 | grep -o -E -m1 "[0-9]+"`
pactl move-source-output $SOURCE_OUTPUT_INDEX $SOURCE_INDEX
Now I will try to adjust the code to toggle between "monitor" device.class and device.class "sound" when the script is called. Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you provide any guidance on how to convert a JavaScript
RegExp
to one thatgrep
will match?