The tag has no usage guidance.

learn more… | top users | synonyms

-3
votes
1answer
42 views

How can i replace a specific string within a line inside a text file [duplicate]

$ cat text.txt my name is Steven my age is 10 i like dogs What command will be fitting so that echo "Kate" will replace Steven on text.txt?
0
votes
1answer
82 views

How to replace \1\ with new line

I have a record like: "evSchema"\1\"UAT" "evSN"\1\"uadb" "evDirsep"\1\"/" "evRootPath"\1\"/work_area/APP_UAT/" "evSchema"\1\"RMS13" "evUser"\1\"STAGE" I want to replace \1\ with new line. I tried ...
2
votes
2answers
21 views

How to replace value for a given condition in specific column of file

I have file separetd by pipe | and I want that when column 6 contain letter I print 0758000 in column 7 and when the column 6 contain letter A print 0800000 in column 7, I can not find how to do it!!! ...
0
votes
1answer
74 views

How can I find and replace only in a range of columns?

I have a text file with 9267 lines. I want to find "A" with 5 spaces after it and replace it with "A" with 5 spaces before and after it on all lines, but only between columns 67 and 88. Text outside ...
0
votes
1answer
40 views

How to replace the content of specific column with awk? Tab Delimited File

Here's a similar question but I ran into a problem that was not addressed in the question. How to replace the content of specific column with awk? I want to do something similar, however my file is ...
1
vote
2answers
32 views

Sed Replace Around Numeric Content

I'm modifying an html output <td nowrap align="right">4683</td> I'd like to replace all occurrences in the document matching this pattern, where 4683 may be any given number varying in ...
0
votes
3answers
49 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
163 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
136 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
61 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
64 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
130 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
32 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
95 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" ...
2
votes
0answers
120 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 ...
3
votes
1answer
78 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
80 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
206 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
133 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
41 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
182 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
190 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
46 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
357 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
476 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
204 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 ...
-2
votes
1answer
546 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
96 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
138 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
252 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
121 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
1k 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
391 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
667 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
69 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
92 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 ...
5
votes
3answers
471 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
2k 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
3k 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
599 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
1k 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
187 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 ...
5
votes
3answers
11k 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
92 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}) ...