Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
1 answer
92 views

I want to change the \]\[ to , in the string below: \[\["2026.04.05 17:52","Powerloss",24\]\]\[\["2026.04.05 17:52","Powerloss",24\]\] How can I do that? I ...
user2090479's user avatar
Best practices
0 votes
6 replies
100 views

Working on the frontmatter of Markdown notes, I'm trying to upgrade the frontmatters with sed. I can do several substitutions and addings together : sed -i.bak \ -e '/---/,/---/s/ creation/__dc/' \ ...
FrViPofm's user avatar
  • 363
Best practices
0 votes
4 replies
139 views

I want to replace one or many occurrences of a certain string with the content of a file, e.g. This is some text with a certain string to replaced with the content of a file. The string to replace ...
user30424's user avatar
  • 271
-4 votes
1 answer
93 views

I have a file with the following content: /opt: dev = /dev/hd10opt log = /dev/hd8 mount = true check = false /tmp: dev = /dev/hd10opt log = /dev/hd8 ...
Aires69's user avatar
  • 79
8 votes
6 answers
587 views

Here is the output of my curl command (print headers only): HTTP/1.1 200 OK Server: CacheHTTPd v1.0 Date: Thu, 08 Jan 2026 19:21:11 +0000 Content-Type: application/octet-stream Content-Length: ...
Ramesh's user avatar
  • 81
Best practices
1 vote
8 replies
152 views

I have a file example.txt with the following content: Begin of file BEGIN 1 2 3 4 5 6 7 8 9 10 END End of file I want to replace every second line inside a matched space of sed. So I tired cat ...
christian2222's user avatar
-1 votes
3 answers
109 views

I want to delete all lines that end with OFF except if they contain override. Input 1765193089 socket override DiningRoom/Socket/Work/state ON 1765206025 socket evening Hall/Socket/Lantern/state OFF ...
Richard Barraclough's user avatar
3 votes
4 answers
177 views

I am trying to replace elements on an array using a sed command to compare values between two arrays and replace them accordingly, with the following terminal input: #!/bin/bash icons=("" &...
Caio's user avatar
  • 75
-4 votes
2 answers
122 views

I want to edit a file in a single command to append a line and remove first lines if more than N. The furthest I got was to use sed: sed -i -e "\$a\[$(date '+%F %T')] $1" -e :a -e "\$q;...
hazardous silence's user avatar
1 vote
2 answers
111 views

I'm trying to place the output of awk 'NR==4 {split($0, a, "$"); print a[3]}' filename in sed -i 's/1/2/' hyprpaper.conf such that 1 is replaced by the output of the command awk 'NR==4 {...
user avatar
1 vote
2 answers
138 views

I have 2 files of data and I'd like to add data from one file to the other, but rather than appending to the file as a whole I'd like to append line-by-line. E.g. I have: ip.txt 192.168.0.10 192.168.0....
thirstyice's user avatar
2 votes
5 answers
118 views

I am playing with text automatically converting to markup. I can make sed enclose some inline code: echo "this is inline_code test 1_2 (_)" | sed -re "s/([a-z0-9]+_[a-z0-9]+)/\`\1\`/g;s/...
thomas's user avatar
  • 266
1 vote
5 answers
153 views

I have a long file, where lines are sometimes split up with an equal sign, followed by \r\n. Example: Hello wor=\r\nld. I want to delete all instances of =\r\n, so that the offending lines are joined ...
dzher's user avatar
  • 45
0 votes
1 answer
108 views

Pulling my hair out, looping over 100K S3 files in AWS Cloudshell; to copy in place to kick off a file processing lambda. when I run my for loop with an aws s3 cp on the dataset I want to, the for ...
areeekay's user avatar
3 votes
2 answers
87 views

The following two sed commands works. sed -E "s#Example(.*)#\nconst ex='Example\1';\n#; s#Input:(.*)#const\1;#" in.txt | sed '/\S/!d' However, how to rewrite them so that only one sed ...
albertkao9's user avatar
1 vote
2 answers
74 views

I've been struggling with this for quite a while. Little differences in escaping and the inner workings of sed between BSD and linux throwing me off. I want to do something deceptively simple: I have ...
npr_se's user avatar
  • 91
1 vote
0 answers
87 views

I am working on Windows OS. And here is my makefile snippet. COMPILER_ROOT := C:/Users/kpt DATE := $(COMPILER_ROOT)/build/busybox_glob.exe date SED := $(COMPILER_ROOT)/build/busybox_glob.exe sed ...
kathy's user avatar
  • 45
1 vote
2 answers
92 views

I'm reformatting a big file with sample metadata. I have a file (let's call it File2) with the group each sample belong to, with one id and pop per line. My idea was to while read over that file and ...
Pedro Morell's user avatar
2 votes
4 answers
164 views

I want to be able to use sed (POSIX) to replace some text in the output from a command with a different message that includes escape sequences to allow me to set the colour. To illustrate the problem. ...
Mike T.'s user avatar
  • 417
3 votes
7 answers
395 views

I have the following file: line 1 abc line 2 def line 3 ghi ..... ..... I need it to become: line 1 abc line 2 def line 3 ghi ...... ...... I know how to remove newlines, but not odd or even line ...
klatls's user avatar
  • 57
2 votes
8 answers
191 views

I have a fastq file containing several sequences with headers such as : tail SRR11149706_1.fastq @SRR11149706.16630586 16630586/1 CCCAACAACAACAACAGCAACCTCCTCACGCCAACGCCGATCCCGCCGCTGTTTTCCAA @...
CaroZ's user avatar
  • 149
6 votes
5 answers
158 views

Source lines formatting, for example: Value11 | Value12 | ValueA,ValueB,ValueC Value21 | Value22 | ValueA2 Desired output: Value11 | Value12 | ValueA Value11 | Value12 | ValueB Value11 | Value12 | ...
access_granted's user avatar
-1 votes
1 answer
71 views

I have this sed command for adding a password to a file: sed -i "s/password:/password: $escaped_password/" "$file" If I replace the $escaped_password with the password, the script ...
aurelianr's user avatar
  • 549
7 votes
7 answers
146 views

I would like to filter word between two patterns. In this case, between CN= and a comma (,) Input: Subject : "O=This is a test,CN=abc.def.com,L=North,ST=Arizona,C=CA" Expected Output: abc....
Raj87's user avatar
  • 145
0 votes
4 answers
140 views

What I want to do is say I have the multi-line string: 1.10... 1.11... 1.12... 1.13... ... 1.18... I would like to match 1.1([0-9]) and replace with 1.1(\1+1) if \1 is the captured digit from the ...
Kaloyan Georgiev's user avatar
-1 votes
4 answers
172 views

I have a curl response with some plain strings like below - "version":"1.1.8". I would like to extract 1.1.8 from the raw text using sed or awk. I tried the below ...
user51's user avatar
  • 10.6k
0 votes
1 answer
36 views

I'm trying to figure out how the i command in BSD/macOS sed works. From the man page, it looks like sed -e '/^/i\' -e $'\t' <<< a should print: <tab>a (where <tab> is a tab char, ...
Camden Narzt's user avatar
  • 2,073
5 votes
4 answers
89 views

I want to replace top 3 lines of my file. For this task, these two commands work fine, but then I get two .bak (saved) files... These work: sed -i.orig1 '1,3d' /my/path/file; sed -i.orig2 '1s/^/line1 ...
Rajeev's user avatar
  • 1,487
3 votes
4 answers
133 views

I am working in a USS environment, under z/OS. I need to insert a new line in a file, the line has to be inserted after a certain row number. I've tried to use the command sed '4i\newtext' file.txt ...
Fabiana Bordacchini's user avatar
-1 votes
1 answer
193 views

Looking for a suggestion that would be much faster. I have a large (232GB) file mongo backup. I want to take out only the April 24th lines and make a new file containing only this date or any date of ...
user3008410's user avatar
2 votes
4 answers
147 views

Problem I was trying to get sed command to do the same thing I could do with Python regex flavour, but I encountered some problems Python regex example: (tested it on regex101 and it was working fine) ...
Signor Pizza's user avatar
-2 votes
1 answer
104 views

I can't seem to get the needed string with sed. Can someone help me see my error? I have tried so many combinations, but no luck. I know it has to be simple, but I'm at my wits' end. echo '/documents/...
user3008410's user avatar
2 votes
5 answers
204 views

I want to do simple string replacements with sed to rename some files. Unfortunately it does not work the way I expect. My Input (these files): 'Djrum - Under Tangled Silence - 01 A Tune For Us.flac' '...
exocortex's user avatar
  • 563
0 votes
4 answers
92 views

I have a Jenkinsfile which analyses some local artifactory server for new versions of the parent and dependencies. When I confirm that there is a new version, I want to replace the old version with a ...
JoSSte's user avatar
  • 3,482
-2 votes
1 answer
131 views

I have a requirement where I have to extract the Jira ticket number using sed regex. I am using a self-hosted Windows runner. I have used solutions from other similar posts on Stack Overflow but ...
pogbamessi's user avatar
12 votes
7 answers
1k views

There are many lines in a file, like the following: 000100667 ===> 000102833 005843000 ===> 005844000 011248375 ===> 011251958 I would like to insert specific separators into the numbers ...
kuninox's user avatar
  • 165
0 votes
3 answers
229 views

I want to replace a? with b? where ? is a character, not a wildcard. Here is what I tried: echo "a?c" | sed 's/a\?/b?/' I expect b?c, but it returns b??c. I also tried two backslashes ...
SantK's user avatar
  • 95
-4 votes
1 answer
102 views

I have an XML file that contains the following data: <Extrinsic name="CommodityVendor">1234567</Extrinsic> <Extrinsic name="buyerVatID">1122334455</Extrinsic&...
user3152289's user avatar
1 vote
1 answer
117 views

I am dumping the output of the mkfs into the log file, but it displays its process interactively, printing backspaces to get cursor back, then prints spaces to erase, then doing backspaces again and ...
Anonymous's user avatar
  • 811
6 votes
6 answers
263 views

I would like to ask about extracting specific strings from a file using sed and regular expressions. Below is the example of the input text file (testfile.txt): # This file contains a short ...
JH Park's user avatar
  • 89
-2 votes
5 answers
130 views

I am using bash on Ubuntu server. My goal is to get the lines from specific section. I can't think of what tool to use to accomplish this (awk, grep -P, sed, ???). It is the specific section that I ...
user3008410's user avatar
0 votes
4 answers
197 views

This question is based on How do I fix sed commands becoming extremely slow when load is high? with the advice of @markp-fuso, @jhnc, and @Jetchisel to avoid a chameleon question as many of the ...
Bryan Tan's user avatar
  • 362
4 votes
7 answers
554 views

I have a bash script that takes a simple properties file and substitutes the values into another file. (Property file is just lines of 'foo=bar' type properties) INPUT=`cat $INPUT_FILE` while read ...
Bryan Tan's user avatar
  • 362
2 votes
2 answers
94 views

I would like to inject to in docker bash file 2nd line (after #!/bin/bash -x) such a command: set -a && . .env && set +a. I've tried this inside source.sh: TEXT_INSERT='set -a &&...
Ainz Sama's user avatar
-1 votes
5 answers
108 views

I have a file that is full of lines like: snprintf(log_buffer,... ... ... ... ); If I use sed, I can find these lines with "snprint.*...
Jonathan Leslie's user avatar
0 votes
3 answers
104 views

I was trying to match date in apache log in many format as you can see below Regex101 https://regex101.com/r/Cug8lX/1 The regex is working but with sed, I can't succeed to make it match. It don't say ...
BeowolfK's user avatar
0 votes
9 answers
219 views

Here is a challenge for regex gurus. Need a very simple sed expression to select text between markers. Here is an example text. Please mind it can contain any special chars, TABS and white spaces even ...
Ramanan T's user avatar
  • 563
4 votes
5 answers
205 views

I have an html page that has data like so: <td><a href="test-2025-03-24_17-05.log">test-2025-03-24_17-05.log</a></td> <td><a href="PASS_report_test_2025-...
Archie's user avatar
  • 389
3 votes
4 answers
104 views

I have some extraneous html table rows I'd like to remove using sed. I want to match and delete these two lines. [tr] [/tr] I've tried sed -i '/\[tr\](\r|\n|\r\n|\n\r)\[\/tr\]/d' ./file which matches ...
ClassyUnderexposure's user avatar
2 votes
5 answers
212 views

I have a script that runs a grep command and formats the results nicely for me, asking if I want to open any of the resulting files in an editor etc. The core of my script is a command like this: grep ...
Robert Mark Bram's user avatar

1
2 3 4 5
581