Linked Questions
19 questions linked to/from How can I output only captured groups with sed?
1
vote
2
answers
270
views
Regex extract substring after '=' sign [duplicate]
I saw many examples, but for some reason it still does not work for me.
This is the command I'm executing:
NUMBER=$(docker logs vault | grep Token)
NUMBER=${NUMBER##*": "}
NUMBER=$(echo $NUMBER | ...
0
votes
0
answers
40
views
Is there a simple way to save variables from sed/awk? [duplicate]
I'm struggling with the following:
Current File:
text1,text2,add(a,b),text3
Target File:
text1,text2,a b c,text3
where a and b vary.
Example:
text1,text2,add(11,12),text3
text1,text2,add(41,42),...
527
votes
10
answers
650k
views
Capturing Groups From a Grep RegEx
I've got this script in sh (macOS 10.6) to look through an array of files:
files="*.jpg"
for f in $files
do
echo $f | grep -oEi '[0-9]+_([a-z]+)_[0-9a-z]*'
name=$?
...
264
votes
17
answers
202k
views
Only get hash value using md5sum (without filename)
I use md5sum to generate a hash value for a file.
But I only need to receive the hash value, not the file name.
md5=`md5sum ${my_iso_file}`
echo ${md5}
Output:
3abb17b66815bc7946cefe727737d295 ./iso/...
127
votes
6
answers
300k
views
How to extract text from a string using sed?
My example string is as follows:
This is 02G05 a test string 20-Jul-2012
Now from the above string I want to extract 02G05. For that I tried the following regex with sed
$ echo "This is 02G05 a ...
58
votes
4
answers
79k
views
sed - how to do regex groups using sed
Is there anyway you can do regex match group using sed like java regex pattern/match/group?
if i have string like
test-artifact-201251-balbal-0.1-SNAPSHOT.jar
how do I use sed just to get the ...
25
votes
4
answers
56k
views
capturing groups in sed
I have many lines of the form
ko04062 ko:CXCR3
ko04062 ko:CX3CR1
ko04062 ko:CCL3
ko04062 ko:CCL5
ko04080 ko:GZMA
and would dearly like to get rid of the ko: bit of the right-hand column. I'm trying ...
9
votes
3
answers
12k
views
Performing regex capture and then substitute using SED/PERL
I have a data that looks like this (let's call this file submit.txt):
dir1/pmid_5409464.txt
dir1/pmid_5788247.txt
dir1/pmid_4971884.txt
What I want to do is to perform an inline file regex change
so ...
3
votes
6
answers
4k
views
How do I output only a capture group with sed
I have an input file
Werkzeug==2.0.2 # https://github.com/pallets/werkzeug
ipdb==0.13.9 # https://github.com/gotcha/ipdb
psycopg2==2.9.1 # https://github.com/psycopg/psycopg2
watchgod==0.7 # https:...
0
votes
2
answers
1k
views
How save each Capturing Groups of a bash regex?
To make it really simple, I must use a regex to select string in a complex file.
I would like to "save" in a file some part of the regex selection. So I use capturing groups and... I don't know how to ...
-1
votes
2
answers
838
views
Extracting text with sed and conditionally present white space
I am trying to dynamically find a directory the be used programmatically later on in a script. The problem that I am having is accounting for white space which may or may not be there.
Using the ...
0
votes
1
answer
381
views
Regex in sed to match a subpath in a path with capturing groups
I have a list of dictionaries, made by two files named index with extension {aff,dic} like
dictionaries/dictionaries/bg_BG/index.dic
dictionaries/dictionaries/ca_ES/index.dic
dictionaries/...
1
vote
2
answers
290
views
Extract a section in a config file line using sed
I'm trying to continue to extract and isolate sections of text within my wordpress config file via bash script. Can someone help me figure out my sytax?
The lineof code in the wp-config.php file is:
$...
0
votes
1
answer
402
views
replace capture match with capture group in bash GNU sed
I've looked around to find a solution to my problem in other posts listed bellow, but it looks my regex is quit different and need special care:
How to output only captured groups with sed
Replace one ...
1
vote
8
answers
158
views
Get the character that precede each occurrence of given character/pattern in a string
I'm trying to get the character that precede each occurrence of given character/pattern in a string using standard bash tools as grep, awk/gawk, sed ...
Step I: get the character that precede each ...