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

1
vote
2answers
149 views

Replacing a string by a file using Sed

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 ...
0
votes
3answers
41 views

csv file adding and removing characters from rows

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
77 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
29 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
28 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
24 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
2answers
67 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
139 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
54 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
13 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
47 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
95 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
49 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
135 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
59 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
542 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
49 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
76 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
64 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
1answer
241 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
236 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
121 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
640 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
122 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
127 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
54 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
215 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
284 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
133 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
77 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
208 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
92 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
598 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
208 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
964 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
789 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
168 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: ...
2
votes
5answers
264 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
479 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
73 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
166 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
36 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
164 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 ...
0
votes
1answer
617 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
2k 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
661 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
413 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
379 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 ...