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

5
votes
5answers
275 views

How to get text from range of dates using grep/sed in large text file?

I have big file text (almost 3GB) - it is a log file. I want to get lines of text which correspond to a range of dates from this file, from 13 July to 19 July. My log format is: 2016-07-12 < ?xml ...
1
vote
1answer
37 views

How can I remove the first whitespace of every line of a file?

I have a file that looks like SPT-CL J0000-5748 J000106.23-574536.8 0.275980 -57.760231 0.7554 0.0003 template 1 SPT-CL J0000-5748 J000049.27-574637.3 0.205320 -57.777050 0.7018 0.0002 template 1 ...
5
votes
2answers
635 views

Make sure that there's a character at the end of each line

I have file with following content. This is, are,,, a,, I want to replace the end of the line with single comma. If there is no comma at the end of the line then add one comma and if there are more ...
5
votes
2answers
270 views

Why doesn't my awk pattern match the configure arguments of nginx -V?

I am trying to get just the configure arguments of compiled nginx on Ubuntu 14.04 using a command line. Running /usr/local/nginx/sbin/nginx -V gives us: nginx version: nginx/1.8.1 built by gcc 4.8....
0
votes
2answers
61 views

How to install gksu on 15.04? [closed]

I'm unable to upgrade 15.04 to 16.04 LTS. Support has ended and all codes to edit sources.list have failed to work. I cannot use gksu since I don't have it and I'm unable to install it from software ...
2
votes
1answer
11 views

sed: Insert a string containing path delimeters

I want to insert a line into a file at line 13 using sed. This is what I tried: sed -i '13/home/me/dostuff.py &' /etc/rc.local I get this error: sed: -e expression #1, char 3: unknown command :...
12
votes
3answers
1k views

Why does redirecting sed output to same input file make my machine unresponsive?

I was trying sed to replace some keywords in a large file (100 MB). I was unaware of the -i (inplace) option, so my first attempt was to redirect like this: sed 's/original/edited/g' file.log >&...
3
votes
4answers
63 views

formatting with awk

I have this text: Core/Dev Core/master FrontEnd/Dev FrontEnd/DoubleClick FrontEnd/HEAD -> FrontEnd/master FrontEnd/master Infrastructure/Dev Infrastructure/master Software/Dev Software/Control ...
0
votes
1answer
24 views

Replace a string with other one [duplicate]

I want to replace a string "#security" with "security\n\tauthorization : enabled" in a file file.txt. Here \n represents a new line and \t for tab. How can I do this using sed command.
0
votes
1answer
41 views

Replacing a variable permanently in shell [duplicate]

I have file <temp_test.sh> in which I have defined a variable Min_Inc=300000. I then want to get the user input to change the value of Min_Inc. I followed these steps. Read the value using ...
0
votes
0answers
62 views

Extract data from logfile from only the previous 24 hours, with bash in a shell script

Using the Ubuntu 14.04 trusty and transmission log for the log file. What is the best way to extract the last 24 hours of log entry's? I have attempted using sed awk grep I cannot seem to get the ...
1
vote
1answer
34 views

sed replace string with some kind of placeholder

I am pretty new to UNIX. I am trying to replace maxretry = * in the fail2ban config file with maxtretry = 3, so that every single packages has max. three retries until the ip is blocked. I know that ...
0
votes
1answer
102 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' /home/d/Desktop/Sandberg/...
0
votes
3answers
17 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
90 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
91 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
1answer
41 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
42 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
25 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
26 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 Dir=E:\test1\...
0
votes
2answers
36 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
54 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
45 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
232 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
115 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
231 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> <p&...
-1
votes
2answers
687 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
66 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
73 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
125 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
119 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/') > /etc/...
3
votes
1answer
64 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
37 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 human-...
-1
votes
1answer
53 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
48 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
49 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
59 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 name="encryptData">false</...
1
vote
3answers
303 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
32 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
66 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
34 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?
2
votes
4answers
187 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
84 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 http://old-releases.ubuntu.com/ubuntu/...
0
votes
0answers
27 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 "27i\$text$...
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 '/denm\....
5
votes
4answers
745 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
233 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: "00005cea-668e-4475-9e19-92a25c8b74fb",129.24728,"D#"...
4
votes
2answers
1k 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 ...