Linked Questions
11 questions linked to/from How to insert the content of a file into another file before a pattern (marker)?
1
vote
2
answers
3k
views
how to insert file contents on match using sed - first occurrence only [duplicate]
file contents:
# cat file.txt
-----
MATCH
-----
MATCH
-----
MATCH
-----
# cat text.txt
add this text file
before first match
sed commands:
# sed '0,/MATCH/r text.txt' file.txt
-----
add this text ...
0
votes
1
answer
1k
views
Replace the keyword with the whole content of another file [duplicate]
I write a bash script to replace the keyword with the whole content of another file.
Here is the command I use:
sed -i "s/CONTENT/$(cat $pathB)/" $pathA
A file
Here is my introduction:
...
1
vote
1
answer
54
views
Displaying a file in another file [duplicate]
I was wondering how to print the contents of a file above the occurrence of a pattern in another file. I know that using
sed -n '/^PATTERN/i\\
INSERTING' filename
would insert above the pattern but ...
57
votes
4
answers
105k
views
sed - replace string with file contents
I have two files: file1 and file2.
file1 has the following contents:
---
host: "localhost"
port: 3000
reporter_type: "zookeeper"
zk_hosts:
- "localhost:2181"
file2 contains an IP ...
9
votes
3
answers
10k
views
Insert text from file inline after matching pattern in another file
I'm trying to take the contents of a file and insert it after a matching pattern in another file using sed. My question is very similar to this question, but I wish to insert the contents of a file ...
5
votes
3
answers
2k
views
How to insert command output directly into a file before a pattern?
This question and its answers show the content of an existing file ("processedFile") can be inserted into another existing file ("receivingFile") before one of its patterns inside, such that:
sed -i -...
0
votes
2
answers
840
views
sed cannot insert if a file ends with empty line
I have a file uca.xml (Thunar configuration for custom actions):
<?xml encoding="UTF-8" version="1.0"?>
<actions>
<action>
<!--some code-->
</action>
</actions>...
2
votes
2
answers
479
views
How to insert the lines from a file into another file after a key word?
I have one file that contains the following:
10.48.29.68 doggy
10.65.8.184 kitty
10.48.15.104 froggy
I need to insert the contents of this file into my hosts file after the line bc group in the hosts ...
1
vote
4
answers
214
views
How to read lines from a file and combine before a pattern match from another file?
This assistance was helpful, but I am still a bit lost. I'll steal it's super easy format.
How to insert the content of a file into another file before a pattern (marker)?
I have two files.
File 1
...
0
votes
3
answers
652
views
How do add complex text using vim/sed/awk
following older posts (How do I use vim on the command line to add text to the middle of a file? & How to insert the content of a file into another file before a pattern (marker)?), I have a more ...
1
vote
1
answer
153
views
How to insert file on matching pattern with filename?
Suppose I have 3 files:
index.html
And here is foo:
<!-- include: includes/foo.html -->
This can be done similarly:
<code>
<!-- include: includes/bar.txt -->
</code>
includes/...