All Questions
36
questions
2
votes
2
answers
1k
views
grep to match two occurrences of the same pattern with a certain number of characters in between
I have a text file, test that contains the following string
MDXXXXXMD
though in general, X could be any character and M could also be F. I'm trying to select for this string with the following grep ...
1
vote
1
answer
348
views
regex in find doesn't accept the or operator in group
I'm trying to delete all files and directories in a parent directory, with the exclusion of some directories and their content. For this I use find in a bash script on MacOS. It works if I exclude ...
0
votes
1
answer
277
views
Why does this regexp — which attempts to match characters between “@” characters — fail?
I need to extract the second field of selected lines in a GEDCOM file. These lines are all of the following format:
% grep @ /tmp/XYZ | tail -5
0 @X701@ OBJE
0 @X702@ OBJE
0 @X750@ OBJE
0 @X765@ OBJE
...
0
votes
1
answer
125
views
macOS|Unix combine multi-line .txt file into single line with no spaces? (no line breaks)
I've been looking around & I cannot seem to find a command or regex that will do a simple command of combing all linebreaks & spaces in a text file into one line. most of them either add some ...
0
votes
2
answers
61
views
regex in string and output in 2 diffrent columns bash
I'm on macOS Mojave and trying to use regex to output the results of a match in 2 different columns
I have a file that contains these strings:
JJ1111-Aaaaaa-AB-22222222-f_2-777777_S1_L000_trtrt
...
0
votes
1
answer
517
views
Named capture groups from command line
I've come up with the following regular expression:
\[release(\s+(?<release_type>.*))?\]\n+(?<release_notes>.*)
The idea is to parse a commit message for several params:
[release minor]
...
0
votes
0
answers
340
views
What is Microsoft Word wildcard equivalent to OR operator |
The OR operator in regular expressions is the pipe |.
Is there an equivalent in Microsoft Word 2016 for Mac wildcards?
1
vote
1
answer
1k
views
MacOS sed: match either beginning or end
this has been bugging me for a couple years now.
"match this or that" works.
"match beginning of line" works.
"match end of line" works.
"match beginning of line or end of line", not so much.
All on ...
4
votes
1
answer
6k
views
Grep on macOS: find unique occurrences of a capturing group in regular expression
I am on macOS and would like to get into using grep (or a similar tool) to find unique occurrences of a certain pattern in a codebase. For example, for finding all console.somemethod() calls in ...
22
votes
1
answer
45k
views
does grep regex work differently on mac?
Just trying to figure out basic use of regexes with grep (or egrep) in mac terminal (BSD grep - 2.5.1-FreeBSD).
File to examine (pow.txt) contains the lines :
kiytytytyty
and
blob.mkv
command ...
6
votes
1
answer
23k
views
Using find in macOS terminal with regex
I'm trying to search a folder containing variations on different image filenames:
1_2-300x224.jpg
1_2-600x449.jpg
1_2-600x600.jpg
1_2-768x575.jpg
1_2-802x600.jpg
1_2.jpg
The plan is to find and ...
1
vote
2
answers
2k
views
OSX find with regex for a standard file ending
I'm trying to find all files with a pretty standard file format (all duplicate media types automatically created by Wordpress). Using Regexr, I was able to put something together fairly quickly. ...
7
votes
4
answers
1k
views
Using sed to retrieve part of a line
I have git svn command like this:
git svn log --limit=1 --oneline
It will output oneline like this:
r12345 | <anything, as it is svn comment inputted by svn-user>
I am trying to pipe in sed ...
0
votes
1
answer
236
views
How do you copy files using ditto with backslashes in filenames
Im writing a script to copy files with characters unsupported by Office365 to a cache folder on OSX before removing the characters (that part omitted). This works except in the case of files such as: ...
0
votes
1
answer
1k
views
Remove leading and trailing spaces with Find on OSX
I am trying to remove the leading and trailing spaces for filenames in user Home Folders on OSX.
I have the the regular expression I need to find the leading and trailing spaces.
^[ ]+|[ ]+$
Im ...