The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
3answers
45 views

How to subsitute a string in file with another file?

I have a bunch of files that all contain a string. This string needs to be replaced by the whole content of another file (that can possibly be multiline). How can I do so? What I need is something ...
0
votes
1answer
42 views

How can I use sed to find a string and replace another string on a different line? [closed]

I have a file like this: BEGIN Name "TIPO_RECORD" SqlType "12" Precision "255" Name "Test" SqlType "12" Precision "255" Name "xxxx" SqlType "12" Precision ...
0
votes
1answer
65 views

How to replace multiple occurrences of a pattern with sed

I use the following command to remove surrounding spaces between array keys that are strings or integers in PHP files: sed -ri "s/\[ ([0-9]+|(\x27|\x22).*(\x27|\x22)) \]/[\1]/g" file.php I thought I ...
4
votes
2answers
76 views

Awk inplace option with print statement

In recent version of awk there is a inplace option that can be used to do in place operations similar to sed's -i option. However I can't make it work with print statement. Let's see my example. The ...
0
votes
0answers
20 views

Sed replace with command output [duplicate]

I'm trying to replace text with the contents of a file and I'm getting errors. This works: cat /tmp/test | sed -e "s/__TEST__/$(cat pass)/g" But this one doesn't cat /tmp/test | sed -e ...
1
vote
1answer
59 views

Pattern matching and removal of that pattern using sed

I have 2 files with the following names: File 1: RvA_X-IRB-bil-CA101-0+010000-20150327212332-055582-P File 2: RvA_X-IRB-bil-CA101-1+020000-20150327212332-055582-P I am using this command to match ...
0
votes
2answers
62 views

Search a line and replace line

false###File.txt many rows ###online = false --> ONE SHOT import (delete all table contents before importing) ###online = true --> DIFFERENTIAL import (import without clean the table contents) ...
2
votes
2answers
86 views

SED on Mac OS X

I'm using a MacBook Pro and I want to find and replace a given word with another with sed command, but it makes no changes. What is the problem? sed 's/\<cat\>/dog/g' tt.txt
0
votes
1answer
27 views

Emacs: query-replace prepend text to the found string

The scenario is that I am trying to append a new class to all the style declrations in my css file. So .oldclass{ float : left; } should change to .newclass .oldclass{ float : left; } The ...
-1
votes
1answer
92 views

replace text in a file

are there any usefull command to replace all text that contain number and remove those number . Ex: myimages-202x250.jpg width="202" heignt="250" replace to myimages.jpg width="217" height="317" ...
0
votes
0answers
79 views

Bash - Convert escape character colored text to BBCode

I want to convert a terminal escape-character colored text file to BBCode colored text. For this i've created an Android logfile with logcat -Cd > /sdcard/logcat.txt. The -C switch adds the color ...
2
votes
1answer
70 views

Find/replace on block device?

Let's say I have an unmounted block device /dev/sda, and I want to replace all instances of MyPassWord with XXXXXXXXXX. (Hopefully my goal is obvious.) What's the easiest way to do this?
2
votes
2answers
75 views

Search and Replace question

I need to find all occurrences of AAsomeArbitraryStringBB and replace it with CCsomeArbitraryStringDD. So AAHelloBB Text AAByeByeBB becomes CCHelloDD Text CCByeByeDD. It's important to note ...
1
vote
2answers
62 views

find and replace a value in a line of text

I have a text file which contain only 1 line of text 1314:Battery:1.90:50:30 I'm trying to figure out if is there anyway to do a grep and sed to change the value 50 and 30 to the following ...
1
vote
2answers
122 views

How do you search and replace multiple lines in KDE Kate?

how do you replace multiple lines of code in Kate? The following is the original text: <div id="image"> <br style="clear: left"/> <br style="clear: left"/> <br style="clear: ...
1
vote
1answer
115 views

substitute complex text string in several files that contains special characters

I need to replace a complex string in several files in a directory. The string that needs replaced is: ...
0
votes
2answers
39 views

iterate lines containing zeros in bash

I am having a file which looks like this: 141.519 141.009 140.121 135.519 0 0 0 0 I'm writing a shell script and I want to replace all lines containing a zero with -1e+10. So far, I’ve tried this: ...
-1
votes
1answer
106 views

how to replace a specific pattern from all files [duplicate]

suppose I want to replace abc with xyz in all files in a directory. How do I write a script for this ?
0
votes
1answer
134 views

defining rename command scope; replace word; replace entire file name; wildcards

Im looking to use the rename command to edit file names. More specifically, Im trying to isolate specific pieces to change, or in some cases, the whole name. For example: Lets say I have three ...
1
vote
1answer
42 views

How to replace a symbol in sed only if it occurs before a letter?

In my documents, I have lots of occurences like these: [["A [["b [["8 [["c [["F [["1... What I need to do is to replace double brackets with single brackets, but only if there is a letter after a ...
0
votes
2answers
193 views

Match a whole word (IP address) using `sed`

I have the following line style in a file: 1.2.3.4 1.2.3.4a 1.2.3.45 iaa1.2.3.4ad 11.2.3.4a a1.2.3.4 1.2.3.4> <1.2.3.4> <"1.2.3.4"> 1.2.3.4 hostname I want to replace all the ip ...
2
votes
1answer
355 views

Return count of matches with find/replace using sed

I'm trying to get a count of the number of replaced strings with find and sed. What I'm starting with: # find . -name \*.php -exec sed -i -e "s|finddddd|replaceeeee|g" {} \; This replaces four ...
3
votes
2answers
184 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 ...
-1
votes
1answer
439 views

Regular expression to mask credit card digits in a file

What is the most simplest way to mask all numbers but the last 4 digits of a credit card number in a file using sed. Using egrep with the following regular expression we can find numbers of Visa, ...
1
vote
2answers
84 views

extract certain string, search and replace or keep a longer string contain the extracted value

The input file that needs to be edited is as below (can have more rows): bundle_id target_id length eff_length tot_counts uniq_counts est_counts eff_counts ambig_distr_alpha ...
0
votes
1answer
126 views

How do I replace the '&#x5c' with '/' in file using the command line?

After grep line with AAA/BBB/CCC but the output file consists only the line as AAA"& #x5c;"BBB"& #x5c;"CCC.. How do I fix this?
-1
votes
1answer
45 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 ...
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 ...
4
votes
4answers
227 views

Replace using vim - Replace a pattern […] by a string

I have a file containing lines in below e.g. format - [foo@host.com, bar@host.com], Payment processed - 23499, params = {'invoice':3243} I only want the account numbers i.e. 23499. It's a number. ...
1
vote
2answers
107 views

Using sed to find a word and replace another word

I have a word like "mode v" in a file. I want to replace it to "mode sv". However all my efforts failed as there is space after mode
1
vote
3answers
868 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 ...
5
votes
4answers
355 views

How to replace all the first occurences in matched lines with incremental number?

I have a file like this ... 1562 first part 1563 H col3 H col4 1564 H col3 H col4 ... 3241 H col3 H col4 3242 third part ... I want to replace only the first H in every line to H#, with ...
4
votes
2answers
645 views

Replace very long string in files recursively

I have a very long and complex string in many files and I want to remove/replace it recursively. The string contains many slashes, backslashes and spaces and any kind of special signs. How do I do ...
1
vote
1answer
66 views

Rename Debian package automatically pulled by apt-get upgrade

I have installed package_a with version 1.0. How to configure package control script for package_b (e.g version 1.1) to automatically replace package_a? tried (as described in 7.6.2): Package: ...
1
vote
2answers
84 views

search and replace string

I have a XML tag for example <tag name="abc"></tag> I wanted to replace the string inside "" with the tag name i.e the upper XML tag should be become now <abc ...
4
votes
3answers
427 views

Search and replace strings that are not substrings of other strings

I have a list of replacements like so: search_and -> replace big_boy -> bb little_boy -> lb good_dog -> gd ... I need to make replacements for the above, but at the same time avoid ...
3
votes
2answers
1k views

Find and replace different columns using awk

I try to make a change in a file: Find a certain value and substitute it with another value in a different column using awk. Input (UiO-66Zr-EH.mof): unit ntype qqatom 1 'Zr1' 0.0d0 vibration ...
0
votes
2answers
2k views

Fastest & Most Core way to replace “\r\n” with “\n” in a file?

I suppose tr is a more core method and thus probably a faster way to replace things within a given file. However tr can only replace equal amounts of characters. meaning... 2 characters can only be ...
-2
votes
3answers
506 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 ...
6
votes
3answers
828 views

Replace multiple strings in a single pass

I'm looking for a way to replace placeholder strings in a template file with concrete values, with common Unix tools (bash, sed, awk, maybe perl). It is important that the replacement is done in a ...
4
votes
3answers
159 views

zsh's “echo SomeText >> **/filename” in other shells

I need to fill all files with a specific filename (recursively) with a text. In zsh this can be done with echo SomeText > **/TheFileName I search generic solutions for sh-compatible and/or tcsh ...
3
votes
3answers
9k views

How to replace the content of specific column with awk?

Given there is 40 columns in a record. I want to replace 35th column so that the 35th column will be replace with the content of 35th column and a "$" symbol. What came up my mind is like: awk ...
2
votes
1answer
89 views

CentOS replace config error

I'm currently working on updating our CentOS server, however whenever I'm trying to use yum I get this error. Config Error: Plugin "replace" requires API 2.6. Supported API is 2.5. I'm new to ...
0
votes
1answer
38 views

sed replace misplaces slashes

I have the following code in a LaTeX file: for \emph{service} in \emph{host}.resources: for \emph{file} in \emph{host}.resources: \underline{service}.requires.add(\underline{file}) ...
0
votes
1answer
240 views

Search for pattern across multiple files and replace a sub-part in all occurences

I am helping a friend with her thesis written in LaTeX and I need a quick solution for a "search and replace". Using a terminal in Linux, how can I find the following pattern: \caption{*\cite{*}} ...
0
votes
3answers
58 views

Using sed to perform substitutions in a file

I was trying to replace dates in a huge file using sed. I tried : sed -ie 's/2014-[0-9]{2}-[0-9]{2}/2014-05-07/g' test However, nothing happened at all, my file test is not modified. Do you know ...
2
votes
2answers
2k 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
6answers
537 views

How to search, replace and append a pattern to the end of each line

I have the following list of items: bigBone fishMarket dogCollar ... I need to generate a two character mapping like this: bigBone -> bb fishMarket -> fm dogCollar -> dc ... How can I ...
3
votes
3answers
171 views

How to do more than one substring replace at once in bash?

I have a directory contains image files that are to be echoed in bash. While echoing, I want to replace both file name and extension in single line command. Example files: images/file_name_1.jpg ...
9
votes
2answers
26k views

How to insert text after a certain string in a file?

Right now I'm using echo "Hello World" >> file.txt to append some text to a file but I also need to add text below a certain string let's say "[option]", is it possible with sed? EG: Input ...