Questions tagged [regular-expression]
Regular expressions are a means of matching a pattern of characters within a string.
2,840 questions
-1
votes
2
answers
92
views
find and regex matching behavior? Why won't 'L1[0-6].*' match "L15a"
I'm trying to understand some subtle behavior of find and its -regex option
I am trying to create symbolic links from files entitled slides_.*.pdf in folders that start with L1[0-6]. I tried the ...
1
vote
1
answer
40
views
Where can one find a repository of regex for logcheck?
I was looking at logwatch, but found that it appears to have been replaced by logcheck, and that logcheck is configured by default for just two files using various regexs to match lines in those logs.
...
3
votes
2
answers
193
views
Syntax Error on ssed for Regex Subroutine definitions
I'm stuck with this error without clue or reference how to solve it:
I have this list on text.txt
Angie Apple
Angie Banana
Angie Tomato
Angie Peach
Angie Onion
I'm running substitution through ssed (...
6
votes
3
answers
368
views
Help w/ "posix-extended" regex for 'find'
Can someone explain the issue I've described below, and perhaps suggest a resolution?
I'm trying to process a set of filenames using find. My platform is macOS (Ventura 13.7.7), and the shell is zsh ...
-1
votes
1
answer
76
views
sed: why my regex does not work correctly
So, I'm facing a curious issue with sed; I have reduced my problem down to the following. Why does
sed -e 's/\"\([^\"]*\)\">/\1/' <<< '["\{">'
return ["\{&...
-1
votes
3
answers
175
views
Perl RegEx one-liner that outputs all matches from one line of STDIN
Here is a silly example that effectively illustrates what I need:
echo '"this text", " ", "is in speech marks"' | perl -lne 'print "$1" if /"(.*?)"/'
...
2
votes
3
answers
374
views
sed: invalid usage of line address 0
I need to keep only last 30 days events in the log and remove other data.
Log has timestamp (date +%e/%b/%Y:%H:%M) and next line values like
01/Jan/2025:00:00
value1
value2
...
01/Jan/2025:06:45
...
3
votes
2
answers
182
views
Embedded special characters skewing sed output
The Issue
I've been parsing a file with sed trying to tweeze out the desired data. This has worked fine for most lines in the file but there appears to be some embedded special characters that are ...
0
votes
5
answers
852
views
Extract email addresses from line, with multiple email addresses per line
I have a text file that mixes names and email addresses, in a comma-separated list.
First Person <[email protected]>, Second Person <[email protected]>, Third <[email protected]>
...
-2
votes
1
answer
142
views
sed inplace in selective block
I have a dir containing logstash config files
these files have filter blocks, and sometimes nested child blocks
need to match whole filter block
filter { any text till final matching closing brace for ...
3
votes
6
answers
225
views
regex to find text plus trailing 10+ spaces; sum of two matches' lengths is part of matching condition
I'm trying to clean files that are copy/pasted versions of my Cygwin (mintty) terminal running bash1. Usually, the input and output are separated by a linefeed ('\n'), as expected. However, when I ...
8
votes
1
answer
601
views
Is there any way to see the string that was matched in grep?
I'm not talking about -o option.
Posix says:
The search for a matching sequence starts at the beginning of a string and stops when the first sequence matching the expression is found, where "...
-1
votes
3
answers
110
views
How to remove markdown links from headers with sed?
I'm trying to use sed to remove links like and leave just the title:
## [Some title](#some-title)
This is my command:
sed 's/^\(\#*\) *\[\([^\]]*\)\].*/\1 \2/'
I expect to have just the text without ...
0
votes
0
answers
52
views
Borg files in `~/.local/share/` occur a “dir_open: [Errno 13] Permission denied” error
General overview
With BorgBackup, I do a backup of my whole $HOME. However, some files (all located on ~/.local/share/) occur a rights error. Probably cause it’s ephemeral files belonging to root, I ...
1
vote
3
answers
375
views
How to delete lines with sed if they contain a phrase?
I tried this
sed -i '/^already satisfied$/d' loggocd.txt
but lines like this one
Requirement already satisfied: cryptography in /home/go/.pyenv/versions/3.9.1/lib/python3.9/site-packages
are not ...