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

3
votes
1answer
29 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
26 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
44 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
42 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
36 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
42 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
287 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
25 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
16 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
31 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
30 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
42 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
51 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
24 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
791 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
323 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
216 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
109 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
162 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 ...
2
votes
3answers
1k 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
54 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
1answer
64 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
179 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
750 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
27 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
583 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
108 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
159 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
62 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
104 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]*\) ...
2
votes
4answers
310 views

Using sed, how could we cut a specific string from a line of text?

Using sed, how could we cut a specific string from a line of text? The string -> Email subject: Test email one two Expected response -> test email one two Any help in this regard would be ...
2
votes
3answers
199 views

How can I divide an output with 2 delimiters?

By dividing with the "·" and " " characters, I would like to turn this: Hel·lo my name is E·ric To this: Hel·lo my name is E·ric Hel·lo my name is E· Hel·lo my name is Hel·lo my name Hel·lo my ...
0
votes
2answers
203 views

Filter consecutive identical characters using Sed and Grep

How to find the occurrences of three consecutive and identical word characters, for example "aaa", "bbb" etc using sed and grep? I meant to find out words which have length 3 and are made from ...
2
votes
2answers
359 views

Filter lines based on length using sed and grep

How to locate lines longer than 100 and smaller than 150 characters using sed and grep
2
votes
2answers
280 views

Replace with “sed” a character with backslash and use this in a variable

I have this sting: the string's problem and I want to change this to: file 'the string'\''s problem' My code looks like this: newline=`echo "$string" | sed "s/'/'\\\''/g"` echo $newline | sed ...
1
vote
2answers
75 views

How do I remove comments of files?

I have a dir with many files. I want to remove all the comments of that files. How do I do that? The files looks like this (everything what is between the /* and the */ are comment): /* */ ...
2
votes
2answers
83 views

Shell Programming using sed to delete a line from txt file

I want to remove a line from a .txt file using the grep and sed functions but the output I get does not alter any of my info in the text file. Any suggestions on how to get the desired output? Thank ...
1
vote
1answer
131 views

Find and replace special characters in a directory

I have a number of Windows based .m3u playlists - they start with ..\..\ and have \ instead of / for folder paths, whereas Ubuntu prefers they start with /media/usr/part/dir/ (i.e. the absolute path). ...
0
votes
1answer
25 views

get a tab out of a vector

if I have the first line of my file looking like this NAMES n1 n2 n3 betwen row1 and t1 there are two tabs but there should only be a single tab...the line is in a larger file it is ...
0
votes
1answer
89 views

Search and replace multiple files including subdirectories

I want search for all occurrences of: </form> In the current directory and its subdirectories and replace it with: <input type="hidden" name="_token" ...
1
vote
7answers
683 views

Remove duplicated dots from file name

I have a dir with tons of files inside which have been named in malformed such as file..txt ,file2..txt ,etc... So how to easily remove this second . from file names? Any applicable method is ...
0
votes
2answers
680 views

Using sed to remove all lines containing special characters , numbers, and spaces

So I'm fairly new to using shell--bash specifically--and I'm in the process of writing a script which will translate files containing DNA sequences into a more useful format. Unfortunately, many of ...
1
vote
1answer
74 views

diffrence between two files of different row numbers

Yesterday I asked this question, and got awesome answers, it's really a joy to ask questions on this site. Today I got a slightly different question say I have csv1 1,2,3,4 5,6,7,8 -- 9,10,11,12 ...
0
votes
4answers
62 views

Adding a number to a already present variable sed/grep/awk

I have this in file.txt FORM: lookupfile Version: 1 LookupFile:"$i" How can I find this in the file and add a variable b to the $i. So example INPUT FORM: ...
10
votes
5answers
1k views

Difference of two big files

I have "test1.csv" and it contains 200,400,600,800 100,300,500,700 50,25,125,310 and test2.csv and it contains 100,4,2,1,7 200,400,600,800 21,22,23,24,25 50,25,125,310 50,25,700,5 now diff ...
5
votes
6answers
2k views

Grep beginning of line

I have a file with the following contents: (((jfojfojeojfow // hellow_rld (((jfojfojeojfow // hellow_rld How can I extract every line that starts with a parenthesis?
-1
votes
4answers
79 views

Copy a string occurring before a particular pattern.

I am to copy this emuEventTrapInformative from below. -- Traps emuEventTrapInformative TRAP-TYPE ENTERPRISE compaq VARIABLES { scellNameDateTime, shelfId, ...
2
votes
3answers
487 views

Delete multiple lines from file when text is found

I've seen multiple answers to delete a single line with sed or grep, but I'm in need to search for a line, delete that one, and the 2 proceeding lines. For example, in the file ~/.profile I have lines ...
0
votes
3answers
66 views

Print a string a number of times [closed]

I have a variable numvar which contains a number. CODE something that reads number stored in numvar and then creates the same number of sTrapValue[with a number here that incrementally ...