Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
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/...
ch33zy's user avatar
  • 1
2 votes
3 answers
114 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 ...
T Lytle's user avatar
  • 199
0 votes
1 answer
40 views

To match a digit inside a negated set [duplicate]

I need to match an arbitrary digit inside a negated set, but becasue sed doesn't support \d, I'm not sure how to do it. Works with PCRE, but not with sed: ^[^\d]*\d* Instead of \d, I can use [0-9] or ...
user avatar
5 votes
6 answers
259 views

Regex case-insensitive search, but have output match the case in the regex

Recently I rewrote my program to find English words that are made of chemical symbol abbreviations, for example "HErSHeY". I came up with this dynamic regex: grep -Pi "^($(paste -s -d'|'...
qwr's user avatar
  • 10.4k
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: ...
Christian Cid's user avatar
2 votes
3 answers
62 views

Regex to ignore string before end line

I have CSV files that look like this: "08d43c37-9b43-4030-b1db-558f8bc89d52","0007661355","cus_7luwjohxnnlujhwinhvhtmzc4y","[email protected]","...
C B's user avatar
  • 117
1 vote
2 answers
88 views

Substitute the ICON reference for nothing

On an export file of more than 2600 bookmarks from Firefox, I want to import them into Buku which seems to bug with the ICON in the html file. So I want to substitute the ICON reference for nothing. ...
Boulou's user avatar
  • 21
1 vote
3 answers
135 views

Sed regex find a string in yaml and comment line, preserving indentation

Let's say I have the below yaml: parent: A: name: foo value: x.y.z # check=something # value: "yay" # check=nothing B: name: bar value: p.q.r # check=something # ...
user1452759's user avatar
  • 9,280
2 votes
3 answers
66 views

How to change urlencode spaces inside a sed capture group only?

I have some markdown files with links like this one: [Royal Enfield Flying Flea](RE Flying Flea) And I'm trying to urlencode the second part of the link to become [Royal Enfield Flying Flea](RE%...
Lumen Lohn Freitas's user avatar
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" &...
campbell106's user avatar
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 ...
jdelgado1025's user avatar
0 votes
0 answers
35 views

How to use sed in shell script with value containing line break \n? [duplicate]

In my shell script I have conf=2bi5oIl0hldy/p3fe+KMQTVjUSg89ywhdMCaSOAopEVFM\nKlj4RDJcmNcEa1cgxL3sJNBHrw==\n And I have a ini file that has parameter looks like this: ^PASS= SNlfkDahPoWNYCY0V+...
user1508682's user avatar
  • 1,361
1 vote
0 answers
39 views

Why does an underscore as the last character in a character set cause GNU sed not to match text containing a hyphen? [duplicate]

I've run into very strange behavior I'm trying to understand in sed (GNU sed) 4.8 on Ubuntu. This works: $ echo "[some-text]" | sed -E 's/\[([a-zA-Z0-9\-]+)\]/REPLACED/' REPLACED But when I ...
heraldingpenguin's user avatar
2 votes
1 answer
90 views

In a bash shell script, how to insert a whitespace with regular expression

here is my script #!bin/bash STRING1='abcdefg' STRING2='1234567' SEDPARSE1='sed -e s/.*(bc).*(23).*/\1\t\2/g' SEDPARSE2='sed -e s/.*(bc).*(23).*/\1\s\2/g' SEDPARSE3='sed -e s/.*(bc).*(23).*/\1 \2/g' ...
sshc's user avatar
  • 23
1 vote
1 answer
79 views

Bash: Search for consecutive repetitions of a pattern and replace it with a string containing the number of repetitions

I used pandoc to convert a .docx file to .tex. The original file was a fill in the blank where the blanks were created using the _ character repeatedly. In .tex this has been literally converted to \_ ...
Photon's user avatar
  • 345

15 30 50 per page
1
2 3 4 5
374