All Questions
5,666
questions
-1
votes
0
answers
27
views
Bash Regex Start Anchor w/Character Classes Not Working [closed]
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
$> var=39Q08a
...
3
votes
1
answer
69
views
Making sense of the regex in grep command [closed]
When executing the following command in a bash shell:
grep '^\(.\)*\1$' exp.txt
I expect it to match any line that:
begins and ends with the same latter.
but in reality it matches the following ...
2
votes
2
answers
79
views
Regex using Bash metacharacters in double bracket `[[…]]` command using `=~` operator
The Bash reference manual, in sec. 3.2.5.2 Conditional Constructs, says
It is sometimes difficult to specify a regular expression properly without using quotes, or to keep track of the quoting used ...
0
votes
0
answers
31
views
Delete the first line match for a domain in a list of domains [duplicate]
So if I have a list of domains in a text file:
fake.domain/file
google.com/drive/folders
stackoverflow/questions
google.com/drive/files
I'd want to be able to submit a string "google.com/...
1
vote
2
answers
84
views
Word Boundary in awk
I am trying to extract the lines that contains the word "at" and wrote this
awk '
BEGIN { IGNORECASE = 1 }
/(failed|caused by|errorcode|error code)/ {
...
2
votes
3
answers
115
views
How to match a group exactly zero times
I am trying to match lines that do not contain a sequence of characters using sed. According to the sed documentation (https://www.gnu.org/software/sed/manual/sed.html), you use () in sed when using ...
3
votes
1
answer
173
views
How to retrieve text from the current line at specified cursor position before and after up to specified boundary characters?
Examples of boundary characters can be: "", '', (), space, ^$ (start and end of the line if any other boundary characters are not specified explicitly). Boundary characters should be easily ...
2
votes
3
answers
140
views
Spelling Bee game regex
In the NYTimes Spelling Bee game, you have to make words (4+ letters long) using a set of 7 letters, one of which must be used in the word. This is fairly trivial to make a regex for:
grep '^[bluntam]\...
1
vote
3
answers
83
views
Regex that replace number lower than 100 by a string in sed script
I'm testing regular expressions in .sed script to replace a number < 100. I have to change numbers lower than 100 only in the fifth field of the CSV.
The CSV is separated by commas.
Example CSV:
...
0
votes
0
answers
46
views
Confused about why the regex pattern does not works [duplicate]
I'm using npm ls -a which gives the following ouput:
└─┬ [email protected]
├── [email protected]
└── [email protected]
I'm trying to extract all the dependencies and store it in a file with the following ...
0
votes
1
answer
36
views
In Bash, Multiple Substring before Specific Char and Continue with
I am trying to write a regex that can satisfy the following condition.
first, string will be start with multiple substrings --> ^(aa|bb|cc)
second, then multiple substring it has to be continue ...
3
votes
2
answers
59
views
Git+Bash / GitBash: Add files matching both first-letter-uppercase or all-lowercase filenames of certain pattern along with respective plurals
I have some Laravel/Livewire files matching filename patterns like seen in below:
app/Livewire/String1Table.php
app/Livewire/String1s.php
app/Livewire/EditString1.php
app/Models/String2Table.php
app/...
0
votes
0
answers
43
views
How to check for real numbers in bash script programming [duplicate]
I am learning Bash script and I need to write a conditional statement which make sure that my input string is a real number.
if [ is not a real number ]; then echo "not a real number"
I have ...
0
votes
3
answers
73
views
How to use a variable command in a sed expression [duplicate]
Testing for a simple script but I can't get this variable to cooperate with me. I've tried so many things, single quotes and doubles.
New=$(df -h)
sed -ie "200s|^.*$|"${NEW}"|g" &...
0
votes
1
answer
53
views
Can you replace a substring from a regex match?
I am trying to find datatime stamps that have an incorrect timezone due to Daylight Savings Time (starting or ending). If the timezone is incorrect, I want to replace it with the correct timezone for ...