Skip to main content

Questions tagged [sed]

sed is a command-line stream editor for filtering and transforming text.

3 votes
6 answers
392 views

I've tried using sed for this. I've tried putting the lines of interest in variables as well. I have two examples I want to achieve for now. Lets say I have thousands of urls in a file called links....
shrykullgod's user avatar
2 votes
1 answer
201 views

Just in theory: is it possible to replace the domain string in the compiled binary file with an IP address by editing a binary file in place with sed? (IP address belongs to a different domain, but ...
fxgreen's user avatar
  • 143
0 votes
2 answers
59 views

Logical way would be to use an 's/[\[\]]/_/g' regexp replace, however it does not work as intended to. It replaces a chain of [ and ] with a single _. $ echo 'x[]x'|sed -E -e 's/[\[\]]/_/g' x_x $ echo ...
peterh's user avatar
  • 10.5k
0 votes
2 answers
144 views

So, I was playing around with this answer, when I found that neither printf_stdin () { read input printf "$input" } sed "/lorem ipsum foobar/ { s/'/'\"'\"'/g s/\...
Grass's user avatar
  • 145
0 votes
3 answers
68 views

Need to find the first instance of a string in a yaml file and insert it alond with a couple new lines after a specific line. Trying to find the first instance of 'rtr-*' and copy it out with a ...
Brian K.'s user avatar
3 votes
2 answers
201 views

I'm stuck with this error without clue or reference how to solve it: I have this list on text.txt Angie Apple Angie Banana Angie Tomato Angie Peach Angie Onion I'm running substitution through ssed (...
Zerchro's user avatar
  • 31
-1 votes
1 answer
80 views

So, I'm facing a curious issue with sed; I have reduced my problem down to the following. Why does sed -e 's/\"\([^\"]*\)\">/\1/' <<< '["\{">' return ["\{&...
Grass's user avatar
  • 145
1 vote
3 answers
681 views

This is the content of input.txt: foo-bar foo-baz I want to substitute - with _ and join the two lines. Notice the difference between using -e and a pipe when using sed: $ sed -e 's/-/_/g' -e ':a; N;...
glacier's user avatar
  • 491
1 vote
0 answers
61 views

The following expression is reasonably effective at wrapping long lines of text (for the purpose of dumping to my 128 characters wide terminal window and reading): s~(.{104,124}) ~\1\n~g This ...
Lumi's user avatar
  • 864
2 votes
3 answers
377 views

I need to keep only last 30 days events in the log and remove other data. Log has timestamp (date +%e/%b/%Y:%H:%M) and next line values like 01/Jan/2025:00:00 value1 value2 ... 01/Jan/2025:06:45 ...
Aleksey's user avatar
  • 75
7 votes
1 answer
386 views

The ESC character is 0x1B. In GNU sed, it can be used as 0x1b. It can also be used as \c[ ²; this, however, behaves inconsistently: sed "s/XXX/\c[/" # right-hand side, no problem sed &...
Lumi's user avatar
  • 864
0 votes
5 answers
397 views

I have rules.txt file with sed rules for replacement. s/1/a/ s/2/b/ s/3/c/ etc... I want to replace characters only after certain line 5. This command does not work. sed -n '5,$p' -f rules.txt ...
normal_max's user avatar
3 votes
2 answers
186 views

The Issue I've been parsing a file with sed trying to tweeze out the desired data. This has worked fine for most lines in the file but there appears to be some embedded special characters that are ...
Gandalf's user avatar
  • 33
-1 votes
7 answers
614 views

I want to print a colon after every 2 characters of alphanumeric Value and I found something like below. But I am not sure how to remove initial 2 characters from the output and what is the meaning of ...
user984993's user avatar
4 votes
4 answers
485 views

How to remove comments and newline symbols without using two pipes. I have bookmarks.txt file with comments. https://cookies.com # recipes cookbook https://magicwands.com # shopping I can copy link ...
normal_max's user avatar

15 30 50 per page
1
2 3 4 5
494