Sed is known as a Stream Editor in that it can carry out various filtering and/or transforming functions on standard input or on user specified files.

learn more… | top users | synonyms

0
votes
1answer
31 views

sed: no input file / permission denied

I get a weird error when I run 2 almost identical scripts and I don't get the difference. When I run this script things go well: #!/bin/bash sed -i 's/^\(\s*\)sudo\s*/\1/g' ...
0
votes
3answers
15 views

replace starting numerical digits

I have content as given below. 2 - 2 1.0 2 10. 2 11. 2 12. Groover MP, Fundamentos de Manufactura Moderna, Tercera ed., Mc ...
1
vote
3answers
82 views

How can I extract pdf names from an lftp log file?

I have a log like this : 2016-05-11 07:09:54 ftp://test@test.dyndns.info/test1/fool/1999/How/05%20May/test160511.pdf -> /test/keep/more/use/05/test160511.pdf 0-28442281 33.5 KiB/s i need to ...
3
votes
3answers
83 views

How to remove XML-like tags from input?

I'm updating my .bashrc file to show weather I'm using the line lynx -dump "http://wxdata.weather.com/wxdata/weather/local/14225?cc=*&unit=f&dayf=1" | grep -A 2 -m 1 "<tmp>" Which ...
0
votes
0answers
28 views

Deleting Multiple Strings with sed

I have a very large file from which I need to delete multiple lines . It looks like: CAM_READ_0623233309 /library_id=CAM_LIB_002149 /sample_id=CAM_SMPL_003380 raw_id=G9ALM7U02F5HAW length=383 ...
0
votes
1answer
30 views

Sed command in Ubuntu not working

Whenever i am using my sed command in ubuntu the output is not reflected in the file. sed 's/dog/cat/' me does not change dog hates rat in the file to cat hates rat in the file me.
1
vote
1answer
23 views

how to replace 3rd row in a file using sed?

I need to change a variable in a file using a bash script, i think sed is the way to go but i can't figure out the regular expression. I have tried replacing a character in the file but then ...
1
vote
1answer
23 views

How to replace string containing file path using sed

I want to replace a file path to other using sed. I am attaching a small part of my file Kindly help source file : Dir=D:\test\foo Dir=D:\test\bar the result should look like this ...
0
votes
2answers
31 views

Replacing a Substring with sed

So I've got a line that looks like this ish somelongbullshit:888:morelongbullshitthatcanhaveanything And I want to replace the second : with a tab character. I can reliably match the substring I ...
2
votes
1answer
40 views

How do I use variables and non-variables in a single sed command?

I'm trying to use sed to replace some PHP lines. My problem is I want to replace a line with PHP variables with a string including a Bash variable. Here is an example: sudo sed -i 's/$sUrl . ...
3
votes
2answers
40 views

How to format arp -a output?

I'm trying to format arp -a output to my liking. For example at the moment it outputs: MyRouter (172.16.3.x) at XX:XX:XX:XX:XX:XX [ether] on eth0 PC1 (172.16.3.x) at XX:XX:XX:XX:XX:XX [ether] on eth0 ...
1
vote
2answers
217 views

Crop a string using sed

I have a command that outputs me a list with the following pattern exp_70_T8_s1 exp_71_T8_s5 exp_72_T8_s10 exp_73_T10_s1 exp_74_T10_s5 exp_75_T10_s10 ... How can I get the numbers after "_T" and ...
1
vote
2answers
81 views

remove special character using sed

I have a text file that contains following https://git.centos.org/git/rpms/abc.git https://git.centos.org/git/rpms/abc.git/ https://git.centos.org/git/rpms/abc When I run the following command, ...
1
vote
2answers
220 views

How do I replace '<p>' with '<p>\n' and '</p>' with '\n</p>' using sed?

I have following file and I want to replace <p> with <p>\n and </p> with \n</p> using sed. My input file contains the following lines: <p>This is home.</p> ...
-1
votes
2answers
224 views

How do I call a sed command in a python script? [closed]

Through python script, I am trying to replace a string by a string in a file using sed command. I do that through subprocess.call as it in the script. When I run the command in the shell script or ...
0
votes
4answers
61 views

Replace spaces in a matched substring with underscores

I'm new to the forum so please forgive any syntactical errors in my question. I'm trying to replace spaces with underscores in a matched substring only. I figured sed would be the best editor for ...
1
vote
2answers
38 views

Cut and store a string untill a word is found in bash

I have this string /path/to/www/continued/xyz I want to cut the string till www means I want the string /path/to/www How can I do this in bash
3
votes
5answers
92 views

How to remove lines which contain asterisk by using sed command

I have a file which contain following lines. **;**;**; *(Eng_Sen:This is an apple)*;*(WordID:1 2 3 4)*;*(message:)*; **;**;** I want to delete all the lines which contain following patterns using ...
1
vote
2answers
55 views

Remove everything before first occurence of specified word

How can I remove everything before the first occurence of a specified word using sed? What I have tried so far: echo $(cat /etc/nginx/sites-enabled/default | sed 's/^*.server/server/') > ...
3
votes
1answer
51 views

Why is an extra space getting removed in sed substitution command

I have a data file that has following data in it: abcd.vc.9902 03493092 90239 m abc 131323 78202 g cdb.5491-3 03402394 23241 k I am trying to remove the digits that begin with space. So the command ...
0
votes
3answers
34 views

Convert Number of Decimals Through a Text File

This question's solution may revolve around perl, sed or awk and unfortunately I am not familiar with any of those. My purpose is to convert a computer-generated text file to give it more ...
-1
votes
1answer
51 views

Mass Editing files with 'sed' or similar with different lines

Let's say I have the following files: /etc/dir1/file.txt /etc/dir2/file.txt /etc/dir3/file.txt ... all the way up to dir100 (100 directories), every directory has file.txt. And I have the ...
0
votes
1answer
46 views

Find command replaces text unwantedly

I am running an Ubuntu EC2 instance. I often use find and replace to update, and tweak things which are used in all files. However, when I have to replace PHP code, I inevitably have to replace the ...
3
votes
1answer
43 views

What does the parameter `-e` in `sed` commands do?

man sed says: -e script, --expression=script add the script to the commands to be executed The description on gnu.org says: `-e SCRIPT' `--expression=SCRIPT' Add the commands in SCRIPT ...
0
votes
0answers
7 views

Using variable in sed command [duplicate]

I have the following sed command sed "s|^(.{91}).{9}|\1$var|" Tail_File.txt > Tail_File_Loop.txt var is a variable. The sed command does not replace value of var. I tried using double quotes, curly ...
0
votes
2answers
55 views

Find and Replace with Bash

I'm trying to replace some text with other text in a configuration file. I created a script with the sed command but I'm getting an error. Original Line: <property ...
1
vote
3answers
301 views

Somehow I created a nondeterministic sh script

I created the following script: #!bin/bash cat > Top10 <<EOF Linux Mint 17.2 Ubuntu 15.10 Debian GNU/Linux 8.2 Mageria 5 Fedora 23 openSUSE Leap 42.1 Arch Linux CentOS 7.2-1511 PCLinuxOS ...
1
vote
1answer
29 views

sed Error with Cordova for Ubuntu Touch

i've run into an sed error while trying to build an app for ubuntu touch. http://pastebin.com/uj1VnhFu For some weird reason cordova still uses 14.10 framework as default. Since 14.10 isn't ...
0
votes
1answer
18 views

sed to var which save special characters

Hello I m tring to use sed -i -e s/"$before"/"$after"/g ~/.A/$sfi to substitube an line on a file .A from $before to $after but bouth variables contain characters & and I think is it the cause ...
1
vote
1answer
56 views

Replace word in file with Username [duplicate]

I am trying to replace a word in a text file with the current username. I am trying to do this with "sed" using $USER, but it keeps actually writing "$USER" in the text file instead of my username. ...
1
vote
1answer
33 views

Replacing text in a Shell Script

I am running the command echo 'link_1234' | sed 's|_|&/|g' And it is returns the value of link_/1234 I need the _ to be deleted Is there any way to have the _ be cleared?
1
vote
3answers
113 views

Extract Strings from an HTML file

I need an sh script will get text from an html file I download the file with wget website.com/link_123456789 -O 'testfile.txt' the full contents of that file are located at this pastebin But you ...
0
votes
2answers
71 views

Failed to fetch message while upgrading

I typed the command sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade and got the following error W: Failed to fetch ...
0
votes
0answers
25 views

write variable into specific line [duplicate]

echo -n "##### STATIONS? #######" read station text="stab_site " I need to write echo $text$station into the 27th line of text file. I used below command but it didn't work, sed -i ...
6
votes
4answers
1k views

How to escape “.” with sed or grep?

I have file with denm.xyz denm.abc denm.def denm_xyz denm_abc denm_def I want to extract the ones with . in it. I tried grep "denm\.*" file grep 'denm\.*' file sed "/denm\.*/p" file sed ...
5
votes
4answers
497 views

Merge files using a common column

I have two files out of which I want to create a third which contains all the information. file 1: a 111 b 222 c 333 d 666 e 777 file 2: 111 x1 222 x2 333 x3 444 x4 555 x5 666 x6 777 x7 ...
6
votes
3answers
228 views

What is the sed comand to fix this file so last value on each line is double quoted

I have a file containing two million lines of the form: "00005cea-668e-4475-9e19-92a25c8b74fb",129.24728",D# the last value should actually be: ...
2
votes
2answers
657 views

How to insert multiple lines with sed

I want to add this #this ##is my text before the line the specific line I tried this sed -i '/the specific line/i \ #this ##is my text ' text.txt but it only adds in 'text'. I also ...
2
votes
3answers
363 views

Replace or add a string to a file

I know sed can replace a piece of string within a text file like this : sed -i 's/oldstring/newstring/g' test.txt But, how do I replace the line if it exists and automatically add it on a new line ...
3
votes
3answers
6k views

Extract word from string using grep/sed/awk

I have a string 00:28:04 /usr/lib/jvm/jre/bin/java -DJDBC_CONNECTION_STRING= -Dspring.profiles.active=qa -XX:MaxPermSize=256 and want to extract the word qa that follows -Dspring.profiles.active. ...
3
votes
1answer
97 views

Write a custom lookup script for MusicBrainz Picard

I have a collection of music files (~200/batch) that I need to tag through Picard. The files have no metadata, and the fingerprinting tool is very inefficient (<50% mean accuracy). However, the ...
0
votes
2answers
109 views

Why can't I replace a specific string with sed?

I want to replace the specific string memory_limit = 128M with memory_limit = 512M in the file /etc/php5/apache2/php.ini: sed 's/memory_limit = 128M/memory_limit = 512M/g' /etc/php5/apache2/php.ini ...
-1
votes
2answers
312 views

Find and replace a character in xml file using sed command is not working [closed]

I have an xml file called myfile.xml <!--This is an xml document for test--> <a><!--This is root node--> <b> <c>Hi&Welcome</c> </b> ...
2
votes
4answers
2k views

how to use sed to replace from last 3 characters from string

I have the issue to extract the x amount of characters from string and i have the difficulty enlarging the capability of the expression. I have tried to use the sed command. If i have the string ...
1
vote
1answer
28 views

Is sed the way to extract a number which is to become part of a command line being constructed?

In /etc/knockd.conf I want a command that will be a ufw insert [line number]... command, the line number is dynamic and can be gotten from finding the first ALLOW occurrence in the ufw status numbered ...
1
vote
3answers
1k views

sed command to replace a value in config file

I am using this command: sed -i 's/\(^TestT_STOA_TS1901=\).*/\1N/'/app/test/must/untuio.cf And I am getting this error: XXXXXXXXX:/app/test/must>sed -i ...
0
votes
1answer
222 views

Replace text in file with variable using sed [duplicate]

I need to replace a string in a file by another string which is stored in a variable. Now I know that sed -i 's|sourceString|destinationString|g' myTextFile.txt replaces a string but what if ...
1
vote
3answers
242 views

How do I replace all occourences of a symbol except the last one using sed?

For example, I got a line like this: 44567743346_567864_56788_5677_3 I want to change all the _ into :, except for the last one would change into \. The expected output is: ...
1
vote
1answer
73 views

Help with sed script to remove Wikipedia citation numbers

I am just beginning to learn sed and awk. I have to submit an homework assignment tomorrow, which is a copy-paste from Wikipedia. Just the opportunity to practice some sed scripting! So I have the ...
3
votes
1answer
116 views

Sed word duplication problem

I'm new to sed and trying out stuff to learn. However I'm encountering a problem I can't solve when using sed to remove duplicate words : echo "abc abc def ghi ijk ijk" | sed 's/\([a-z][a-z]*\) ...