Skip to main content
Filter by
Sorted by
Tagged with
3 votes
4 answers
159 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
1 vote
4 answers
99 views

I'm migrating a blog from Jekyll (source) to Hugo (source). Both use Markdown, but their syntaxes are slightly different. Let's say that in the old Jekyll blog I have this: {% include image.html src=&...
Antonio Medeiros's user avatar
0 votes
0 answers
60 views

I have a file that I'm trying to put a spool command and the dos path as the first line: To get the dos path from bash I use: CWDDOS=$(pwd | sed 's/\//\\/g' | sed 's/\\c/C:/g') and it gives me this: ...
Erik Christiansen's user avatar
-4 votes
2 answers
117 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
98 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 {...
itsmongeese's user avatar
1 vote
2 answers
111 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
114 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
  • 256
1 vote
5 answers
140 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
88 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
80 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
70 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
73 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 votes
1 answer
167 views

I have the following source file named test.txt: text before ---BEGIN MARKER--- content 1 ---END MARKER--- text between ---BEGIN MARKER--- content 2 ---END MARKER--- text between ---BEGIN MARKER--...
Wiimm's user avatar
  • 3,753
1 vote
2 answers
83 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
136 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
333 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
189 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
151 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
66 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
  • 551
7 votes
7 answers
140 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
120 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
142 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
0 answers
35 views

TL;DR: Same sed commands (regexp, captures/edits) work in same environment (bash in freebsd 14), running from script, but fail when using -i switch. Why? Background: Debugging a script on bsd (no x-...
mawi's user avatar
  • 182
0 votes
1 answer
33 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,075
5 votes
4 answers
84 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,489
3 votes
4 answers
113 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
189 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
135 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
92 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
197 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
90 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,442
-2 votes
1 answer
116 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
11 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
  • 155
0 votes
3 answers
200 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
98 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
111 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
  • 751
6 votes
6 answers
187 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
127 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
187 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
  • 363
4 votes
7 answers
463 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
  • 363
2 votes
2 answers
89 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
102 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
100 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
213 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
  • 523
4 votes
5 answers
184 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
98 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
200 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
2 votes
2 answers
129 views

First time I have had to post here to solve a problem. I am guessing I am missing something easy. Spent a bout four hours yesterday beating my head up against something I though was going to be simple....
Mathew's user avatar
  • 31
0 votes
3 answers
86 views

I'm trying top use sed to find a block of text starting with "listener socks5 {" and ending with "}" and append a line to the end of the last "map" entry. here's the file ...
Fermichem's user avatar
  • 137
0 votes
2 answers
95 views

So, I'm trying to be clever and slice out the output of virsh via read so I can make something cool. (That's open to interpretation.) However, my little script is not working like I expect. The ...
Decoherent's user avatar

1
2 3 4 5
581