All Questions
50
questions
0
votes
1
answer
92
views
Iterate over all matches in a file for a regex pattern in zsh
What is the tersest way to efficiently iterate over all matches in a file for a regex pattern in zshusing a completely zsh-native method, instead of using external commands like grep?
Is there any way ...
5
votes
7
answers
273
views
gawk hangs when using a regex for RS combined with reading a continuous stream from stdin
I'm streaming data using netcat and piping the output to gawk. Here is an example byte sequence that gawk will receive:
=AAAA;=BBBB;;CCCC==DDDD;
The data includes nearly any arbitrary characters, but ...
1
vote
1
answer
41
views
regex a period in zsh
I am trying to find out if a hostname has a domain suffix by searching for a period in the string. I can do it in bash with the following
#!/bin/bash
if [[ "$1" =~ \. ]]; then
host="$...
1
vote
3
answers
77
views
How to get image red green blue standard deviation values from gm identify -verbose?
I am trying to get the values given for Standard Deviation in the Red, Green, and Blue channels that you can see in gm identity -verbose but they're not listed in the -format options.
How can I get ...
0
votes
4
answers
188
views
How to capture app version to console via grep and regex?
My regex is weak. I am ashamed, but it's true.
I can log the entire line containing a Mac app's (Xcode's) version to the console via a command like this:
defaults read /Applications/Xcode.app/Contents/...
0
votes
1
answer
45
views
regex query for filenames with multiple numbers at the beginning of the filename
I am trying to create a regex query. I need the regex query to extract filenames from a directory.
I will run the regex query via a bash/shell script
It is important that only files are found which ...
0
votes
2
answers
108
views
Perl regex positive lookbehind to search through newline and space
I'm trying to automate updating of my ~/.ssh/config file. When I do an online regex tester it works as I want to with PCRE2 (so perl 5.30.3 compatible) at regex101, but when I try to replicate on my ...
0
votes
1
answer
60
views
How can I use a regular expression to remove the file extension in zhell?
I am trying to simplify my command line java using this zshell script where $1 holds the file name, in this case Hello.java.
# jcr stands for java compile and run
jcr() {
javac $1 # $1 contains ...
0
votes
1
answer
107
views
Removing trailing whitespace in Zsh: fatal error: out of heap memory
Anybody know why I'm getting this and how to prevent it?
#!/usr/bin/env zsh
setopt nullglob
setopt extendedglob
for file in **/*; do
if file -b $file | grep -q "text"; then
raw=$(<...
0
votes
1
answer
128
views
regex works in perl, fails to match in bash, works in zsh but BASH_REMATCH is empty
for d in "A - test1 (a)" "B - test2 (b)";
do
if [[ "$d" =~ -\s(.*?)\s\( ]];
then
D="${BASH_REMATCH[1]}"
echo "$d --> $D : $BASH_REMATCH"...
-2
votes
1
answer
60
views
(Another) Correct (?) regex not understood by sed
According to https://regex101.com/r/KVQPk0/1, the following regex (in my real use case, I need the group for back references):
<latex>\$([^$]*)\$<\/latex>
(full) matches the string <...
2
votes
3
answers
227
views
Matching a string with whitespace character in bash
Basically, my goal is to print the rails version as a prompt segment to the terminator(terminal) as we enter a ROR project.
I have figured out a way how to display it as a custom segment in the ...
1
vote
1
answer
293
views
ZSH regex pattern matches in tester but not in use
In a zsh shell script (sdk.sh) I have a command that can be input four ways, according to user preference. The script should figure out which pattern the input is, then act on it accordingly.
My ...
1
vote
2
answers
1k
views
Unbind all tmux prefix key
How can unbind default prefix key in tmux?
I mean the default set by the user, Not necessarily C-b
I do not know what the user has set! So I have to discover the prefix with the command
solution ...
3
votes
1
answer
6k
views
how to use regex variable in zsh?
How can I use a regex variable in zsh the same way it works in bash? I can only get zsh to work with an inline regex. I am just trying to test a string only contains alphanumerics, underscores or ...