The tag has no wiki summary.

learn more… | top users | synonyms

5
votes
4answers
209 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
75 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
34 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
36 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
107 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
157 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
52 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
136 views

Replace $ with £ using sed command

I have text file DollarToPound.txt with some Dollar signs ($). Please provide a shell script to replace dollar symbol with Pound (£) with sed command. I am getting: batch@BATCH:[~/output]$ ./del.sh ...
4
votes
3answers
167 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
116 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 ...
2
votes
3answers
227 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
47 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
28 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
97 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
37 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
252 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
276 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
66 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 ...
2
votes
2answers
1k 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 ...
7
votes
3answers
898 views

How to remove a specific character in a string but only if there are no numbers in that line in Linux

I've been stumped with this seemingly simple-to-fix problem.. well, for a while. Here's example output from the file I need to edit: $cat file George Washington Geneva Convention 123,281,029 USD ...
0
votes
1answer
41 views

text replacing in data file with peculiar spacing

I have a text (.qdp) file with many data stored. In some rows, the data are too many to be on just one line. Then, the program that saves the data, use a minus sign (-) to go on the new line, and ...
5
votes
2answers
1k views

Remove unknown unicode character from textfiles - sed, other bash/shell methods

I need to search and replace all occurences of an unknown character in some files having the same name. Opening such files with vi, I read <91> code for that character. Opening them with nano, I ...
1
vote
1answer
142 views

Problem installing input-wacom-0.20.0

I run Linux Mint 14. I bought a wacom intuos pen&touch small tablet and my old driver (don't know which one, someone installed it for me...) does not support it. I did a little research and found ...
1
vote
1answer
104 views

Sed: search and replace a patten with special characters which has a arbitrary string in between

I have a load of nfo files which I want to make some global substitutions for some values within each file e.g. a.nfo has the value <set>Tonight&apos;s Menu ( June 2012 )</set> ...
1
vote
1answer
289 views

Replace spaces and tabs at the end of the line in all files

I need to replace all unwanted spaces in all files from the current directory and from directories from the current directory (recursive search). I define the unwanted spaces the spaces and tabs that ...
0
votes
1answer
211 views

Copy file while replacing text in it

I'm writing a script to publish a webapp. While copying files, I must replace a placeholder current_date in a file with the current date. I would start with something like this to define the date ...
0
votes
1answer
70 views

How to add parens around text

How can I use sed to replace text and also append to end of line for the match in question? I have a sed file which is doing many substitutions. One of them changes ~= to match( using /=\~/ ...
4
votes
3answers
269 views

how to emulate “replace a b b a” with a sed?

I am trying to emulate a replace command which swaps two characters, with a sed script, but the obvious choice: sed -e 's/a/b/g' -e 's/b/a/g' does no work. Can you point me how to do it correctly? ...
2
votes
1answer
28 views

Replace output occurrences

Let's say I have this output: 0001 0002 0003 0004 0005 and I want to replace the first two zeros (00) with (01). What is the simplest way to achieve this?
0
votes
0answers
15 views

using tops command to update NSLog statements in cocoa code

In my objective-c code base I have several NSLog statements. eg. NSLog(@"Here is the message without arguments"); NSLog(@"Here is the message with arguments: %s, %s","argument1","argument2"); Now ...
6
votes
2answers
197 views

How to report “sed” in-place changes

When using sed to replace strings in-place, is there a way to make it report the changes it does (without relying on a diff of old and new files)? For instance, how can I change the command line ...
3
votes
2answers
730 views

Replace a pattern in a file with a long string

I'm writing a little shell script to generate a directory listing. To make the output easily customizable, the script just builds a HTML-table and than should replace a specific token in a template ...
1
vote
0answers
67 views

Automatic replacement of strings in gedit

I want to replace some strings defined by me in gedit, after a word has been completed and/or the document has been saved. For example \ðrac should be replaced with \frac How do I do this in gedit or ...
3
votes
5answers
348 views

How to grep, then search and replace on the output?

I have some output from iconv, e.g. $ iconv -l | grep ISO | head -5 CSISO4UNITEDKINGDOM// CSISO10SWEDISH// CSISO11SWEDISHFORNAMES// CSISO14JISC6220RO// CSISO15ITALIAN// durrantm:~ How can I change ...
7
votes
2answers
644 views

How could I use Bash to find 2 bytes in a binary file, increase their values, and replace?

I'm trying to find two bytes inside binary file, then increase value of those two bytes and replace them inside file. Those two bytes are on positions 0x82-0x83. For now on I have successfully ...
4
votes
2answers
1k views

Merge folders and replace files using CLI

I want to update some forum software and I'd like to test the upgrade process using CLI as a learning possibility. How do I merge contents of a folder into another folder and replace files?
4
votes
3answers
592 views

vim - how can i do a 'change word' using the current paste buffer

I have some text in my paste buffer, e.g. I did a yw (yank word) and now I have 'foo' in my buffer. I now go to the word 'bar' and I want to replace it with my paste buffer. To replace the text ...
5
votes
3answers
178 views

How to insert text after the last configuration line?

I have to insert a line into a configuration files automatically, but with the added caveat that it should be inserted before a multi-line footer comment and any preceding empty or whitespace-only ...
1
vote
1answer
252 views

How does one find and replace text with geany in all files in a directory?

I see this discussion: How does one find and replace text in all open files with geany? I want to find and replace all files in a directory. The method suggested in the answer, is very good to find. ...
5
votes
4answers
440 views

sed how to substitute when string has “http://” in it?

I have a file xx that has the following contents: @base_url = "http://dmstaffing-stage.herokuapp.com/" I want to use sed to eliminate this line (replace with nothing). I have used this sed ...
5
votes
3answers
4k views

Use sed to find whole word and replace

I have the following block of text in a file: test3.legacy test4.legacy test3 test3.kami I only want to search for test3 as a whole and replace it with nothing. Unfortunately, all my attempts have ...
1
vote
2answers
191 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 ...
2
votes
2answers
6k 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 ...
4
votes
2answers
279 views

Why does this add spaces? echo “x ax” | sed 's/x\s*/x /'

I want to find a x, and replace the 0 or more following spaces (\s*) with just a single space. echo "x ax" | sed 's/x\s*/x /' For some reason, instead of replacing the spaces with the single space, ...
2
votes
1answer
763 views

How to fix networking driver boot load failure after replacing hardware?

After replacing the motherboard, which is the same as after replacing the network adapter interface hardware (NIC), our Debian 6.0.6 no longer loads the networking driver on boot. The manual approach ...
-1
votes
1answer
64 views

Replace AAA for BBB in file

Given I have a file with several words, how can I do the following: How can I replace AAA for BBB in a file with Unix?
3
votes
2answers
115 views

How to convert *text* to {\i text} with sed?

I would like to replace every occurrence of *text* into {\i text}. text *text* text *text* text *text* *text text text* text should become text {\i text} text {\i text} text {\i text} {\i text ...
2
votes
5answers
466 views

Replacing lines in files with file contents

I have several files which contain some PHP includes and I want to substitute them with the file contents. The file looks like foo <?php include("file1.php"); ?> bar baz <?php ...
2
votes
3answers
1k views

Substitute placeholders in template

Say I have a shell configuration file config like this: HOST=localhost PORT=8080 Now I have a template template like this: The host is <%= @HOST %> The port is <%= @PORT %> How do I ...
2
votes
2answers
207 views

Copying hashtag comments recursively within <blocks>

I have two files, one with blocks like <record> line1 line2 line3 #model bla bla bla </record> while the other file has exactly the same number of blocks, but without the hashtag ...