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
2answers
41 views

Forming IPAddresses from Text file

I have a huge text file that contains IP addresses scrambled all over but not in one unit for example. So what the@192@ heck are you doing@168@ in my house @10@.you were not @16@ supposed to be ...
1
vote
3answers
167 views

Remove quotes around integers in a csv file

In a large (>1 gb) csv file I have something like "34432", "name", "0", "very long description" but instead of that I'd like to have 34432, "name", 0, "very long description". I was looking at ...
1
vote
1answer
104 views

How to copy a part of a line to another position

I have about 100 print statements in a file like this: printf("%f \n\n",row1.req_pnttime); I want to copy the variable name inside the string so that it becomes like this ...
-1
votes
3answers
80 views

How do I replace content of XML file by using shell scripting sed command?

I have a config.xml file which shows: <userid>myUserId</userid> <password>myPass</password> How can I replace myUserId and myPass by using sed?
2
votes
1answer
48 views

using Sed to search and replace text in XML file

I have the following text in File.XML: <!--UpdateAccountGUIDs>UpdateAndExit</UpdateAccountGUIDs--> I would like to replace that with ...
4
votes
2answers
55 views

Using Regex Breaking a text on the last digit using linux tools like sed, or awk

I have the following list that I want to break on the digit. For example: From: 103Ru 103mRh 104 1041 To: 103 Ru 103 mRh 104 1041 I would like to use Regx with sed or maybe awk in order to ...
2
votes
1answer
35 views

Filtering a line with sed

I have a file with columns of the form number_number number columns of numbers I want to extract the columns beginning with particular numbers. I tried the following, but get nothing in output: ...
2
votes
5answers
228 views

Help to build this expression using sed

I have a text file and I need to get rid off the entire information just before the = symbol in each line, for example: The line: File 1515 = foo.txt needs to look like this: =foo.txt So, I had ...
3
votes
2answers
94 views

sed not found but already installed [closed]

I'm using Ubuntu 13.04. I'm trying to install ptxdist-2011.11.0 and when I run ./configure, it says it doesn't find a sed version: checking sed version... configure: error: we need at least GNU ...
1
vote
2answers
56 views

Help about sed command

A Linux textbook covering sed command gives me an example as follow: sed -e 's/\(<[^ ]*>\)\([ ]*\)\(<[^ ]*>\)/\3\2\1/g' GNU Linux is cool Linux GNU cool is but while I typing exactly ...
3
votes
2answers
129 views

How to make sed works with break lines from file?

I'm adapting this script to insert file's content into another file. This is what I have now: #!/bin/sh # Check if first and second parameters exist if [ ! -z "$2" ]; then STRING=$(cat $1) # ...
0
votes
1answer
30 views

Count length of letter string

I have a file that look like that (DNA sequence in fasta format): >sequence_name1 ATCGTGATNNNNNNNNAGTCGATCGGATTCT >sequence_name2 NNNNATGTNNATGTCCNNNNNNN I want to count the length of gaps, ...
0
votes
1answer
107 views

sed, grep, and awk file sorting

I'm trying to get all the files which have 'load' in their names from a directory. I'm trying to do: find -type f | sed -s 'load However, I recurrently receive an error sed: -e expression #1, char ...
1
vote
1answer
147 views

Bash script, cannote replace string in a file with escaped $ and &

I have creatd a shell script which takes a string as input. If the string contains '$' or '&', then I need to raplace those characters with '\$' and '\&'. I could done that with sed command. ...
0
votes
2answers
133 views

How to sed and replace string with a folder path

I am trying to write the following bash script: HOME_DIR=/opt/my_home find ./CONFIG -type f -exec sed -i "s/_HOME_DIR_/$_HOME_DIR/g" {} \; The line that I want to be changed in the files is this: ...
4
votes
1answer
161 views

Convert all letters to uppercase in all text files from a directory

I have a lot of text files (with .txt extension) in one directory in which I want to convert all letters to uppercase. How can I do this using the terminal? I've tried: sed -i 's/[A-Z]/[a-z]/g' ...
1
vote
1answer
139 views

what this command do ? ls /usr/bin | grep ”man” | sed ”s/man/###/”?

I have a question I want to know what this command do ls /usr/bin | grep ”man” | sed ”s/man/###/” I have use this command and show me everything with ###, but I dont know whats mean. I hope ...
1
vote
2answers
102 views

Remove all lines that start with a hash from a list

For a simple example say I have list file which has the following contents cat dog pig dog hat cat clap sing king ca cat hog plate plate one two three cat I then have a 'pattern' file. With the ...
0
votes
1answer
183 views

How to replace strings in file without regex?

I need to replace some strings in files (from command line) but I don't want to use sed -i because my string contains lots of funny characters which need to be correctly escaped. Is there a way to ...
1
vote
1answer
104 views

How to sed two words in a line and add before and after?

I was curious to know if there is a better way to sed two words and add a line before and after them. I learned how from grymoire but I wanted to know if there was a better way to do: #!/bin/sh ...
0
votes
2answers
79 views

sed problem with scripting

I am trying to run a script using sed i runing like this for et in 1 # 2 3 do if [ -d ET$et ]; then rm -rf ET$et; fi mkdir ET$et cd ET$et cp ...
-1
votes
2answers
87 views

Reading a file line by line

I have a file that looks like: @ATDGGSGDTSG NTCCCCC + nddhdhnadn @ATDGGSGDTSG NTCCCCC + nddhdhnadn Now its a repeating pattern of "4" lines and I every time want to print only the 2nd line i.e. the ...
0
votes
1answer
30 views

Formatting a file to use it with fortune in the terminal

I have a big text file with 'Terms' and its 'Definition' separated by spaces(variable). I want to use it in fortune cookie format. Current file format: **term1** this is my definition with ...
1
vote
1answer
107 views

How to use sed with this complex expression of special chars and ips?

How to use sed to replace for example this expression: connection = sqllite///keystone@10.10.10.51 with this expression connection = mysql://keystoneUser:keystonePass@10.10.10.51/keystone
1
vote
4answers
1k views

How to remove special 'M-BM-' character with sed

File: https://dl.dropboxusercontent.com/u/32919746/file I have file that was created by copying content from DOCX document with LibreOffice into text file. I have modified file with sed to remove ...
0
votes
2answers
142 views

How to get sed to substitute for all but one character

I have a statement of the form atPhysAddress[1][1.10.0.0.98] i would like to remove all details except for the first one in the second bracket, or whichever value falls there, how can i achieve ...
6
votes
3answers
6k views

Sed substitute through a sentence on multiple lines

I am new to using sed but I have been experimenting sed's s/..../..../ (substitute) to modify a full sentence if it's on one line but I am unaware an alternative solution on how to modify a sentence ...
3
votes
2answers
169 views

How to batch organize files?

I have a directory with gigabytes (about 8gb) of small individual files. I want to organize them into directories by date. The date it was created is part of the filename. Here is an example of a ...
0
votes
1answer
183 views

search and replace inconsistency between vim and sed

Using the Ubuntu 12.04 and vim 2.22.0, why inside the vim I shall use: :9s/\d\+/1/ to change first digit of the mentioned line to 1, but couldn't be able to use the same with sed as : sed -i ...
1
vote
2answers
1k views

sed command replace text with ' character

I have an very big sql file that I cant open in a gui editor. I need to replace the string 'user1'@'localhost' (note the ` character) by 'user2'@'localhost' but i am having troubles finding the ...
0
votes
1answer
36 views

Detecting the fault in my sed command

I am creating a command to replace all instances of ; f. to , (frequent). . So i wrote sed -i 's:;[:space:]f.:,[:space:](frequent).:g' with out any change then i wrote sed -i 's:; f.:, (frequent).:g' ...
2
votes
2answers
278 views

What is sed and what is it used for?

I've been seeing a lot of sed lately, and I find it to be a rather confusing command. The manpages weren't particularly helpful, but I do know that it can be used for parsing the output of other ...
1
vote
1answer
318 views

Tell sed to make changes but those starting with a specific string in 8th to last line

Here again with another problem with sed. As the title says, I want sed to change lines starting at the 8th line to the end, but only lines which start with <b>. I have code all ready and ...
1
vote
1answer
118 views

Change a string keeping some text as it is using sed

I have got another problem here with SED. I wanna add some text to a string but with out changing a particular word which varies with every line. Or wrap a code on a string keeping it as it is. ...
2
votes
1answer
751 views

Change specific lines using sed

I have a html file and i want to edit from 8th line till next to the last line i.e no changes to 1-7 and the last line with sed utility. Example: line 1 <i>some text<i> line 2 ...
2
votes
3answers
3k views

Print text between two XML tags

Consider the following excerpt from a large XML file: ... <serverName someKey="false" anotherKey="0.05" thirdKey="0.04"> <default>blah.blah.blah</default> <region ...
1
vote
1answer
74 views

sed does not work

I tried to use the sed command to do some text replacement, sed -i 's/port=\"8080\"/port="\8000\"' /opt/apache-tomcat-7.0.37/conf/server.xml But I meet this error: sed: -e expression #1, char 9: ...
4
votes
2answers
131 views

Print text file every three line start at 2nd line

I have done it with simple loop to count and print through.. How can I do it in bash scripting with program such as sed,awk ?
2
votes
1answer
138 views

Need help in SED and AWK

I have a file "list" as following: main.c getname 25 main.c getage 36 util.c namecheck 123 The above has first string file name, second function name, and third line no. I want to: Open the ...
6
votes
3answers
4k views

How to run Ubuntu without GUI in Virtual Box?

I have a Windows XP laptop, in which I run VirtualBox with the latest Ubuntu, my hardware is little old, so running the latest version of Ubuntu inside Virtual box is kind of a hassle, very slow ...
7
votes
3answers
2k views

Replacing dots (.) in sed

EDIT: After using cat -A myfile it seems problem that those spaces are not spaces, but M-BM- special character. Using any symbol . as Oli suggested for search is not good idea as there is risk some ...
0
votes
2answers
915 views

Inserting variable into sed command in bash script

I have text file similar to this: Some-text Keyword Some-text Some-text Keyword Some-text Keyword Keyword I want to replace every "Keyword" with "number.extension" where number is 1 at first ...
2
votes
5answers
263 views

sed/awk make lines starting with lower characters be merged to previous line

Here is what I have This is a sample text How to do it ? I need the output to be: This is a sample text How to do it ? In addition, how can I achieve the same with: This is a sample text How ...
1
vote
0answers
143 views

sed/awk - remove all tags except only two tags and plain texts

here is a sample for my text file: <w:r><w:t> <w:r w:rsidR="00D171FD"> <w:t></w:t> </w:r><w:r> <w:t xml:space="preserve"> This is a sample text ...
1
vote
1answer
195 views

Configure Fail2Ban with bash script

I'm trying to configure the /etc/fail2ban/jail.local config with an bash script. I was thinking to use sed and regular expression to change the sections I need. sed -i "s/^bantime = 600/bantime = ...
3
votes
2answers
697 views

how to remove two forward slashes in a comment with sed

I have a configuration file and I want to replace a line containing a specific string, lets say test : file.conf aaa bbb ccc // test ddd // test My line of code is not working, I'm new to sed. ...
1
vote
2answers
582 views

How to replace an atypical pattern in a text file using sed

I have an MRTG configuration file containing lines starting with the word "Target". Now in such lines there is a pattern starting with the character "#", and ending with character ":". A sample line ...
2
votes
1answer
97 views

How to replace primary key in MYSQL using SED

I need to replace the pattern: \(d+, to (. How can I do that? Because when I exported db I need to remove the id column which is auto increment. INSERT INTO `users` VALUES (22,'xxx@gmail.com' ...
2
votes
1answer
450 views

How do you use sed to edit a CSV file?

I have a CSV file like this: hostname1 | role1 | environment | tag,list | | hostname2 | role2 | environment | tag,list,longer | | hostname3 | role3 | environment | | | I need a sed expression that ...
1
vote
2answers
203 views

how to reverse the lower case characters in word using only sed

Reverse every word of a line using sed Description ----------- The job to do is reversing every word of a line. that a word is a sequence of lowercase alphabets Raw Input ...