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
4answers
249 views

How to select and print IP address from a set of strings?

I have a sentence whic contains an IP address. For example, This sentence contains an ip number 1.2.3.4 and port number 50, i want to print the IP address only. From the above sentence, I want to ...
0
votes
1answer
30 views

How to get indirect access on a file through script in linux

I have one file text1, on this only one user(user1) has read,write,execute permissions, rest of the world(user2) has read and execute permissions. I thought of having one script which changes the ...
0
votes
2answers
34 views

Insert text into file

I'm trying to insert some text into a file on a specific line which I have managed to do with sed the below being inserted into line 34 of the txt file. sed -i "34i some text" name_of_file.txt The ...
3
votes
6answers
288 views

rename multiple files with delimiters

How could I rename multiple files like, IonXpress_049.T11014.R_2014_11_13_11_26_35_user_PR2-41-Pooling0026_3140_13112014.bam ...
4
votes
4answers
350 views

How to find all patterns between two characters?

I'm trying to find all patterns between a pair of double quotes. Let say I have a file with contents look like as following: first matched is "One". the second is here"Two " and here are in second ...
1
vote
2answers
126 views

How do I replace a string on a large file? [duplicate]

I'm having big WordPress SQL dump file on my Ubuntu server which is around 7GB. Since I'm changing domain I need to replace the domain name in the file. I want to know how to do it via command line. ...
2
votes
2answers
71 views

Sed matching problem, output not as expected

What I need to accomplish: I want to recursively match everything from string1 to fixed_string (both included) on text_files and output the results onto a result_file. My command is as follow: sed ...
0
votes
2answers
81 views

How to replace a string of text with input from another file

I am working on a script to configure a server. Basically the script installs several services and copies configuration files in to place. I would like to replace the username in one of the ...
2
votes
3answers
48 views

SED \n and \ into nothing

The people on this forum have been a tremendous help! Thank you so much! Here is my string ...
5
votes
2answers
225 views

How to save matched pattern into variable using 'sed' command?

I'm trying to find a pattern using sed command in file.txt between first char1 and char2 and then replace that with string. like below with echo mode example: echo "This X is test Y. But X is not ...
0
votes
1answer
67 views

Locate two variable strings and write one as a file [closed]

I have a text document that contains 2 lines of information. Line 1 contains a filename, and line 2 contains an reference ID. The document contains additional strings other than the desired ...
1
vote
2answers
197 views

Replacing a string by a file using Sed [closed]

Lets say i have two files foo and bar. I want a replace the string "this is test" in foo with the contents of the file bar. How can i do this using a one liner sed? I have used: sed -i.bak 's/this ...
1
vote
3answers
65 views

csv file adding and removing characters from rows [closed]

I have a big csv full that looks like so else if(a,b,c,d,e) else if(a,b,c,d,f) I want to make it look like so else if(a+x==b and b+x==c and c+x==d and d+x==e) else if(a+x==b and b+x==c and c+x==d ...
2
votes
1answer
109 views

Sed Script - Reversing names

I have a text file with several names that are arranged with the First name first, and the Last name second. How can I use Sed to reverse this order of names so that the Last name is first, and the ...
1
vote
3answers
45 views

Sed to change a birth date using a regular expression

I'm interested in changing a birth date in a text file to a different date of 11/14/46. I want to do this without having to know the previous birth date and instead be able to search generically. I ...
0
votes
1answer
43 views

Appending to end of a line using 'sed'

I have a line that says... Fred Flintstone, Bedrock USA and I want it to look like... Fred Flintstone, Bedrock USA *** How do I append a few * to the end of the line using sed command?
0
votes
2answers
33 views

Sed to delete blank spaces

Does anyone know how to use Sed to delete all blank spaces in a text file? I haven been trying to use the "d" delete command to do so, but can't seem to figure it out
1
vote
3answers
78 views

Replace a specific section of code

I don't know what could do this, sed, vim, whatever. Lets say I have 30 functions, to keep it simple, i'll show 3 #first function AddOne = [ a+1==b, b+1==c ] # second function ...
2
votes
2answers
289 views

How do I replace multiple lines with single word in file(inplace replace)?

Content of my filename file is as following(for example): My block of line starts from here START First line second line third line END and end to here for example. I want to replace block of ...
1
vote
3answers
86 views

Deleting column in vim

I have a tab-delimited file like: name1 verb1 name2 verb2 etc... I want to delete the second column. I tried editing one of these answers, but being not familiar with sed and awk, I ...
1
vote
0answers
30 views

Ubuntu Suspend issue with Self Encrypted Disk

I have a computer with a self Encrypted Drive (a hard drive with an AES encryption chip that requires login at boot to decypher the disk, that way it is hardware encrypted which "in theory" means zero ...
1
vote
4answers
116 views

using sed replace the new line with character

I am using sed command to remove the new line and replace with <br> but I am not able to get the desire output. I wrote : find . -name $1 -print0 | xargs -0 sed -i '' -e 's|\n|ABC|g' but ...
1
vote
3answers
148 views

Not able to run sed on bash script

I am working trough some legacy code which does not work, I came across a part that is causing problems. I was hoping some one could help me out and fill me in on what is the exact functionality of ...
9
votes
9answers
1k views

Remove the first part of a string using sed

How do I get from this: randomcollege-nt\user90 to this: user90 using sed?
-2
votes
1answer
84 views

Change time format in log file

I have squid log file in follow format: 31/Jul/2014:13:44:52 +0400.701 0 172.16.204.59 TCP_DENIED/407 5232 GET http://vec01.maps.yandex.net/tiles? - NONE/- text/html but log analyzer need time ...
2
votes
2answers
143 views

append a word to the end of a line in txt file

I have a file that should have "OK" at the end of a certain line the line that should be modified is the first line not ending with "OK" I can grep the file to get the line to be modified using ...
0
votes
2answers
73 views

Using Ubuntu command line to replace text in huge file

I have a huge XML file that I must work with. Right now the file is only 1 line that contains about 2 million characters which represent 30,000 records. There are no carriage returns or linefeeds ...
6
votes
4answers
580 views

how to delete line numbers in a code block?

Generally codes published in web pages contains line numbers. When I copy and paste code into text editor (though some text editors remove line numbers automatically, but somtimes it doesn't work), it ...
0
votes
3answers
59 views

How can I replace all the characters from a string?

I have the following string signaldate signaltime period UwThiSon3dH140__mean UwThiSon3dH140__sigma I tried to use sed to replace the space with comma. sed 's/ /,/g' sed 's/[[:space:]]/,/g' but ...
0
votes
1answer
180 views

Linux : Data extraction from text file

I have a text file in which thousands of data is there. eg. id=row_value profile=row_value name=row_value email=row_value address=row_value id=row_value2 profile=row_value2 name=row_value2 ...
1
vote
1answer
90 views

Can I use a Bash variable in a sed command?

I'm trying to execute a sed command with "-n" option. for i in 1 2 3 4 5 ; do maas maas nodes list | grep hostname | cut -d\" -f4 | sed -n '$ip'; done I want it to run sed -n '1p' then sed -n '2p' ...
1
vote
2answers
329 views

sed “Permission denied” and “No such file or directory” errors while building Clockwordmod

Whenever I execute the command build/tools/device/mkvendor.sh samsung_aegis2vzw /your/path/to/the/boot.img I get this as the output build/tools/device/mkvendor.sh: line 83: /sedcommand: ...
1
vote
3answers
448 views

How can we remove text from start to some particular selected word using sed command in linux

I have a simple query related to selection and replacing text in linux. For explaning question I am using sed command. I have following text. hello world, I am just simple text for display. Now ...
0
votes
0answers
181 views

sed fix for BusyBox - boot fail unable to mount LVM

BusyBox why u no vi?! Summary: Ubuntu 14.04 Server after upgrade first boot, only boots to BusyBox v1.21.1 initramfs with "gave up waiting for root device" due to missing /dev/mapper/xxx-root as ...
3
votes
1answer
847 views

Delete the whole line starting with a special character except for the first word

I have very recently started using linux and I am almost completely oblivious on sed commands. I need to edit a file that contains a bunch of long lines starting with the common character ">" and ...
1
vote
3answers
220 views

sed replace text containing new line

I have a bash script for installing a web server on my Ubuntu server. I'd like, in the /etc/apache2/apache2.conf, to replace #ServerRoot "/etc/apache2" # by #ServerRoot "/etc/apache2" ...
2
votes
1answer
210 views

Trying to use GNU Parallel with sed

Why does this line do nothing? I'm trying to run a "sed" command in parallel and it outputs nothing to "standard.txt" $Filetemp = the file I'm stream editing standard.txt = the file I'm outputting ...
0
votes
2answers
58 views

Regular expression

I have a code that is looking for a specific pattern in my log files. Usually it begins with Association ID = (This is what I am looking for in parenthesis). Now the code I have made so far is ...
6
votes
2answers
251 views

Piping with Moreutils ts

I have an incoming stream at a serial port, with new lines appearing about once per second wren@Raven:~$ cat /dev/ttyUSB0 A_Sensor1,B_22.00,C_50.00 A_Sensor1,B_22.00,C_50.00 ...
4
votes
2answers
473 views

What is the meaning of :a;$!N; in a sed command?

$ (echo hello; echo there) | sed ':a;$!N;s/\n/string/;ta' hellostringthere Above sed command replaces new line character with the string "string". But I don't know the meaning of ...
1
vote
2answers
156 views

Extract full link of a div element

I'm downloading episodes from a series, but I'm tired for joining in the site, copying the link and downloading it for each episode. First, I join in the site and I get the HTML code. The code is ...
0
votes
2answers
112 views

How this command works

i see this command on other forums as a question for registering "date -u +%V$(uname)|sha256sum|sed 's/\W//g'" i think it depends on the time of my PC witch change every second .. but the output ...
2
votes
2answers
241 views

How to use sed to substitute current date?

How do I use sed to substitute date by a word. I tried doing this: tmp=`date +%d` echo $tmp if [ $tmp -lt 10 ] then pat="d" echo $pat else pat="dd" echo $pat fi cal | ...
1
vote
3answers
100 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
738 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
323 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
1k 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
1k 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
206 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
49 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: ...