Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sed]

"sed" ("stream editor") is a Unix utility that parses and transforms text files.

0
votes
2answers
24 views

insert string before last line in freebsd

I got file with next content: protocol static { route 100.100.100.100/32 via 192.168.56.2; route 1.1.1.1/32 via 10.0.2.15; } And I need to add one route string a.b.c.d/32 via a.b....
2
votes
1answer
22 views

sed-remove all but last occurrence of a character from a line

Suppose I have some lines like author = {Bill Catsman}, title = {{Hello} {{Cruel} {World}}} and I want to remove all but the first and last brackets from title. I can do sed -r 's/title\ \=\ \{//2g' ...
0
votes
0answers
8 views

Use variable inside sed statement

I want to replace the second occurrence of 127.0.0.1 with $IP in the /etc/hosts file there is two 127.0.0.1 occurrence in the /etc/hosts 127.0.0.1 localhost.localdomain localhost 127.0.0.1 ...
0
votes
2answers
21 views

How do I replace a string that contain white space and quotes?

I want to replace $config['module_id']['ra'] ='6' with $config['module_id']['ra'] ='2' in a file, but isn't replaced and nothing happens. Can anyone help me?
1
vote
1answer
37 views

Surround certain string with specified characters using regex-capable editor

I need to format certain string in Sphinx's documentation H2 Header. Example: v-add-user should be replaced with ********* v-add-user ********* I search for needed string in Notepad++ (regex ^(...
0
votes
1answer
16 views

Insert multiline command including variable to a file

I'm trying to create a script to config rc.local file. I need to insert multiline command with variable before exit 0 line. For example, the variable VARIABLE=31 original rc.local file: #!/bin/...
0
votes
1answer
28 views

awk with sed to combine lines and remove specic odd pattern from line

In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There ...
0
votes
2answers
49 views

Reusing stream of sed for string append

TL;DR: Need to reuse stream in sed so that extracted string is added into current line's ending. I have have a script to extract a substring using sed and make a command to copy using this substring'...
0
votes
1answer
23 views

MacOS sed: match either beginning or end

this has been bugging me for a couple years now. "match this or that" works. "match beginning of line" works. "match end of line" works. "match beginning of line or end of line", not so much. All on ...
0
votes
0answers
17 views

sudoers rename cmnd_alias and replace where it is referenced

I need to concatenate hundred of sudoers file in one big file.. it is the requirement the resulting concatenated file must be a valid sudoers file I verify with visudo -cf huge_sudoers if i ...
0
votes
1answer
26 views

Merge lines which are not in proper

I have the lines similar to below. [1] 07:37:38 [bb..], qw, Exited with errojjjvice not known [2] 07:37:39 [bfb.], fg, , This is FILE1, Stderrle or directory [3] 07:37:39 [SU..], b b, ,, Stderr: bash:...
0
votes
0answers
12 views

Wget to build site map, including pages with no TITLE?

I'd like to map a web site that currently has no table of contents. However, some pages are also missing a TITLE line in the HEAD section. I found the following code, but it doesn't include how to ...
0
votes
0answers
126 views

Recursive and massive string replace inside Windows folder

I have a text file with oldstr<tab>newstring lines to replace inside all source files like this: MyOldText (tab) MyNewText MyOldText2 (tab) MyNewText2 How can I massively replace ...
0
votes
1answer
27 views

Replace using SED + Vars + New Line

I'm trying to use a "sed" with new line, but I want to use this new line in a var like this: #!/bin/sh var1='tags' var2='aw1 \n aw2 \n aw3' sed -i ':a;N;$!ba;s@'"$var1"'@'"$var2"'@g' *.html I want ...
1
vote
1answer
93 views

How to replace value with square brackets using sed?

I need to replace variables with square brackets in a file: a=0 foo[1]=0 foo[2]=0 I want to replace foo[1]=0 to foo[1]=2. To change the values a I use: func_update_value () { field=$1 ...

15 30 50 per page