Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sed]

"sed" ("stream editor") is a Unix utility that parses and transforms text files.

0
votes
0answers
31 views

Recursive and massive string replace inside Windows folder

I have a text file with oldstr<tab>newstring lines to replace inside all source files like this: MyOldText (tab) MyNewText MyOldText2 (tab) MyNewText2 How can I massively replace ...
0
votes
1answer
25 views

Replace using SED + Vars + New Line

I'm trying to use a "sed" with new line, but I want to use this new line in a var like this: #!/bin/sh var1='tags' var2='aw1 \n aw2 \n aw3' sed -i ':a;N;$!ba;s@'"$var1"'@'"$var2"'@g' *.html I want ...
1
vote
1answer
43 views

How to replace value with square brackets using sed?

I need to replace variables with square brackets in a file: a=0 foo[1]=0 foo[2]=0 I want to replace foo[1]=0 to foo[1]=2. To change the values a I use: func_update_value () { field=$1 ...
1
vote
1answer
360 views

How to delete duplicate text from a file?

I tried to delete the tect with the following command sed -i -e 's/<check-valid-connection-sql>select 1</check-valid-connection-sql>//g' standalone.xml But its showing me error sed: -...
1
vote
4answers
133 views

how to replace contemporary values in a file

I'm trying to write in a single "file.cfg" the values of two variables generated by two independent scripts. The two variables are constantly updated and saved in the "file.cfg". Below is an example ...
1
vote
1answer
26 views

Using sed to replace single quotes between two characters

I have a string like this: 'abc','D'art','abc' Using sed I can replace D'a for 'D\'a' using: sed -i "s/D'a/D\\\'a/g" file1.sql The problem is that I have a huge SQL file, and every step of the way ...
0
votes
1answer
47 views

Regular expressions with sed (extracting capturing groups)

From the output of: $ pyenv virtualenvs I want to extract with sed the names of the virtual environments as well their path. The same for the default environment is marked with an asterisk. The ...
0
votes
2answers
70 views

Replace leading tabs and spaces with sed

I want to replace leading tabs and spaces with something like <TAB> and <SPACE> respectively. But I couldn't figure out how to do it in a single pass of sed because tabs and spaces in the ...
0
votes
1answer
81 views

grep: memory exhausted - Error running on Large Data Set

I am trying to clean an email list with huge data. When I try this: pv "Email-Raw.txt" | grep -vf <(sed 's/^/^/; s/$/$/' Segment00.txt) > RESULT-1.txt I get grep: memory exhausted How do I ...
0
votes
0answers
35 views

How to substitute the Output file created in round one back into the command in a FOR loop?

I am writing bash shell script, for cleaning emails. I need help to figure out how do you substitute the Output file created in round one back into the command in a FOR loop? Firstly, I decided to ...
0
votes
1answer
38 views

UNIX - Add column at the end of CSV with double quotes using SED

I have data in following format : "1";"abc" "2";"dfg" "3";"hij" I used the following command to add a column: sed "s/$/;"newc"/" file.csv but i get the last column without quotes: "1";"abc";newc ...
0
votes
1answer
20 views

Add variable space at the end of line in file

I want to add white space at the end of each line. Number of white space is in variable. If number of white space is fixed then I can use this command sed 's/$/ /g' for two spaces. space_variable=...
0
votes
1answer
12 views

Sed doesn't take file to work at

When i type grep -r string1 folder/ | cut -d ":" -f1 | sed -i -e 's/string1/string2/' it say sed: no imput files but grep -r string1 folder/ | cut -d ":" -f1 write in stdOut a list of path who ...
0
votes
1answer
23 views

How do I delete lines of 1st file if it ONLY EXACT Matche of the string present in the 2nd file in linux?

Consider I have two text files. First File name - "Emails.txt" with the following data: sale@gmail.com info@yahoo.com all@gmail.com help@domain.com abcdsale@gmail.com abcd.info@yahoo.com Second ...
3
votes
2answers
45 views

To override the contents of files

I have two files, file1.txt and file2.txt, file1.txt is: perimeter a=10 perimeter b=15 perimeter c=20 file2.txt is: perimeter a=12 perimeter b=14 Let me know the sed or Perl to override the values ...

15 30 50 per page