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

-4
votes
0answers
28 views

How to find and replace a particular string in the following manner

My input file is, ami0041 ami00056 ami0029 ami023 ami0099 ami049 ami00999 tumi0234 bichi23455 susami345 Using a single command line I need the output as, ami0042 ami00057 ami0030 ami024 ami0100 ...
-2
votes
0answers
44 views

How to replace first string before first space [on hold]

NC_009925.1_13653 [754389 - 754574] Acaryochloris marina ATTCCTGATTCTCTTGATGAAAGTAACATTATGGATCAT... TATGATCCATTCAGGCATGATGCAAGGCGCTACCCCCAA... 110311 2992101 2992319 len=219 ...
1
vote
2answers
14 views

using sed to remove equals sign from a file

I am trying to use sed to remove the equals signs from this file and pipe it to a new file: I am a file to be edited. A unique file with my own words. T=h=e=r=e a=r=e i=s=s=u=e=s w=i=t=h t=h=i=s ...
-1
votes
1answer
37 views

How to find and replace a particular string by increasing its numerical part?

My input file is, ami41 ami56 ami23 ami67 ami45 ami34 ami88 jama66 tumi234 bichi23455 susami345 Using a single command line I need the output as, ami42 ami57 ami24 ami68 ami46 ami35 ami89 jama66 ...
0
votes
2answers
38 views

Search and Replace from terminal, but with confirmation

In many text editors, you can do a search and replace and be given the option to inspect each found case. I'd like to be able to do something similar to this at the command line in ubuntu. I know ...
2
votes
3answers
203 views

How to find and replace a string by increasing its numerical part?

My input file is, ami21 ami65 ami67 ami66 ami88 ami76 ami29 ami55 ami54 ami32 Using a single command line I need the output as, ami22 ami66 ami68 ami67 ami89 ami77 ami30 ami56 ami55 ami33 I ...
1
vote
2answers
87 views

bash sorting multiple duplicate strings in a file

I have file like below: Personname:Mark Hobby:chess Hobby:tennis Personname:Tom Hobby:swimming Hobby:badminton Hobby:boxing Hobby:music Personname:Nick Hobby:swimming Personname:fabio Hobby:swimming ...
-2
votes
1answer
53 views

compare strings in two files and update the status [duplicate]

i have following data set in text file data.txt: d1,40,gold d2,30,silver d3,20,bronze d4,10,iron d5,5,wood d6,20,gold d7,10,wood d8,5,god d9,10,silver . . . ...
1
vote
1answer
54 views

How to replace word occurrence in ranges specified using sed command?

str="I want to abc replace a word abc in a sentence abc of file abc by giving abc specifying a abc multiple abc range to abc the sed abc command abc." The above sting str has word "abc" 10 times ...
1
vote
2answers
54 views

bash text colon values to html table

i had a big file with more than 10000 recordslike below, this need to be converted to html table i tried various ways with converting into csv and then to html etc.., not able to get the desired ...
0
votes
2answers
57 views

sed : difference between “ sed 's/\-.*// ” & “ sed '/\-/s/\-.*//gw ”

I am learning few simple sed commands and I have gone through few practices. Command #1 sed 's/\-.*//gw witout' tgs.txt Command #2 sed '/\-/s/\-.*//gw with' tgs.txt Output #1 $ cat with 2. ...
1
vote
1answer
36 views

Color the regular expression in same file

I have a big file and need to look over certain patterns. and also look for another patterns based on first pattern and thus this requires to color the lines which matches the search in the same file. ...
0
votes
1answer
33 views

Match Pattern and write following value as variable

I'm trying to match a pattern and then pull the following information to create a file using that variable. Example (my data may look like either of the 2 examples) "headers": { ...
1
vote
2answers
62 views

replace only the first and only the last match using 'sed'

I want to replace, and old string with a new one. This is what I used sed -i "0,|$old|{s|$old|$new|g}" file but it gives me error: sed: -e expression #1, char 3: unexpected `,' How to change it? ...
1
vote
1answer
41 views

What am I doing wrong with Sed

My input: sed -i 's/if ($.browser.msie)/if ($.browser={ msie: ( navigator.appName == 'Microsoft Internet Explorer') ? true : false })/g' file.js I have tried putting the search and the replace ...
0
votes
1answer
68 views

Is it possible to use variable in sed command in unix bash script [duplicate]

I trying to solve following problem. With great helps of others here, I can write and understand simple do loop in bash scripting. Now I try to do this: In "mein_directory" directory I need ...
0
votes
2answers
138 views

How to use sed to find the strings between 2 patterns?

I have file content like this: aaa accounting exec ... aaa accounting exec ... aaa accounting commands .. aaa accounting commands .. aaa accounting commands .. aaa accounting commands .. aaa ...
3
votes
4answers
271 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
34 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
41 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
434 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
631 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
151 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
79 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
114 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
80 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
325 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
68 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
345 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
77 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
130 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
92 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
58 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
64 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
620 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
292 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
1answer
80 views

Ubuntu Suspend issue with Self Encrypted Disk [duplicate]

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
252 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
182 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
3k 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
134 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
155 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
87 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
658 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
71 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
234 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
142 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
431 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
793 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 ...