The tag has no wiki summary.

learn more… | top users | synonyms

10
votes
3answers
11k views

Replace string with contents of a file using sed

I have two different files: File1 /home/user1/ /home/user2/bin /home/user1/a/b/c File2 <TEXT1> <TEXT2> I want to replace the <TEXT1> of File2 with the contents of File1 ...
12
votes
4answers
16k views

Remove line containing certain string and the following line

I use this cat foo.txt | sed '/bar/d' to remove lines containing the string 'bar' in the file. I would like however to remove those lines and the line directly after it. Preferably in sed, awk or ...
6
votes
3answers
5k views

Vim :s replace first N < g occurrences on a line

In vim, I sometimes have occasion to replace the first few occurrences of a match on a line, but not every one like g would. e.g.: a a a a a to b b b a a I know I could use ...
-2
votes
3answers
272 views

Replace $ with £ using cat Command

I have file test_output_archive.svd with some Dollar signs ($). I have generated a shell script Replace_dollar_pound.sh with cat command to replace dollar symbol with Pound (£) script is working on ...
2
votes
2answers
8k views

How can I replace text after a specific word using sed?

I have a file named .ignore. In need to replace the projdir. For example: ignore \..* ignore README projdir Snake I need to replace Snake with, for example, "PacMan". I read the man page, but I ...
1
vote
3answers
288 views

Replace specified character between two strings?

i have something to accomplish. i need to replace all occurrence of & inside or between <ex> </ex> to #. actual example below: a & b & c <ex> a & b & c ...
1
vote
4answers
783 views

Replace text between brackets

I'm using awk '{ gsub(/BAR|WIBBLE/, "FOO"); print }' to replace text in data like: SOMETHING [BAR, WIBBLE] SOMETHING [BAR] This gives the desired result of: SOMETHING [FOO, FOO] SOMETHING [FOO] ...
-1
votes
1answer
40 views

replace pattern matching

I want to replace part of a file's data, with data from another file. Suppose file1 has data as is written below and file2 has some data I want to store replace file1 data from file2 from starting ...
9
votes
11answers
9k views

How can I “cat” a file and remove commented lines?

I'd like to know if there is a way that I could cat file like php.ini and remove all lines starting with ; For example, if the file contained this: ; - Show all errors, except for notices ; ...
5
votes
2answers
3k views

How does one find and replace text in all open files with kate?

How does one find and replace text in all open files with kate?
3
votes
2answers
123 views

How to read needle part of the sed command from a file?

I want to replace a long part of a file with something else preferably by sed but want to read that long part from a file. I already found this: sed -e '/<TEXT1>/{r File1' -e 'd}' File2 from ...
3
votes
5answers
2k views

How to replace a list of placeholders in a text file?

I have a text (configuration) file, but the program that reads the file unfortunately doesn't allow using any kind of variables. So I'd like to use a preprocessor that replaces a set of placeholders ...
2
votes
2answers
1k views

How to search and replace strings matching a replacement list for multiple files

I have a file, say map.txt, containing a list of search strings and corresponding replacements: search -> replacement bigBone -> bb fishMarket -> fm dogCollar -> dc ... I need to ...
2
votes
1answer
490 views

Replace semicolons to commas between the quotes only [duplicate]

Possible Duplicate: Remove comma between the quotes only I'm trying to use awk function to replace the semicolons between quotes to comma and it is 98% ok for me, because I want to keep the ...
2
votes
1answer
341 views

How to join vCards lines

vCard uses a special way to split long lines: At 75 characters, insert a DOS newline and a space. Joining therefore means to replace all occurrences of the sequence "CR, LF, space" with an empty ...
1
vote
2answers
300 views

Search and replace full line in recursive files

I'm using: grep -n -H -o -R -e textword . List all file recursively under directory '.' with string 'textword' and show the file, line and only portion matching. I need to remove lines that ...
0
votes
0answers
26 views

want to replace a file data from another file [duplicate]

I want to replace a file data from another file Suppose file1 have data written below and file2 have some data i want to store replace file1 data from file2 from starting word // +++ CUSTOMIZATION ...
0
votes
2answers
5k views

Replacing one test string with another in particular column

I would like to replace "CC" with "C" and "AA" with A" in a particular column of Tab delimited file (using awk probably).