Sed stands for Stream EDitor - one of the basic tools in the POSIX environment. It processes one or more files according to an editing script and writes the results to standard output. Created in Bell Labs, it has been around since mid-70s.

learn more… | top users | synonyms

0
votes
1answer
65 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 ...
1
vote
0answers
38 views

Sed + how to set parameters in sed command in order to display lines from text file [migrated]

I find the following way to print line from file In this example we want to print the first line from the hosts file sed -n '1,1p' /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 ...
1
vote
0answers
12 views

SED returning error 2 when launched by Wpkg

Case I am deploying a software product using Wpkg over Windows workstations. I need to disable product's faulty automatic update and the best solution in this case is to modify one configuration file ...
1
vote
5answers
126 views

How to split the output into different files?

I have a input file like foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz bar xxx yyy zzz bar xxx yyy zzz foo xxx yyy zzz .. How to split the input file by line, into foo.txt ...
-1
votes
3answers
49 views

Why a sed command stop my log file to be written to?

I launch on a Gnu/Linux server an application myApp: ./myApp &>myApp.log & Of course, the log file will soon become huge. I would like to use sed to reduce it (I'm aware of logrotate ...
1
vote
1answer
57 views

Replacing LineFeed \x0a with SED

I have to delete lots of Linefeeds (Hex \x0a) in a logfile. I just have sed to solve the problem. It is a bit complicated I know.. Do you have idea how to solve the problem? Here is an example ...
0
votes
2answers
48 views

Why does this bash command sometimes return a blank string?

I have the following line to generate a random number: head -c 3 /dev/urandom | hexdump | sed -e 's/[0 a-z]//g' | head -c 1 This works fine but sometimes (very few) it returns a new line. Does ...
0
votes
1answer
47 views

Invalidating email addresses from sql dump before import

Synopsis I would like to import production data into the development environment so testing can be done in an almost accurate way. Of course I need to invalidate e-mail addresses as I don't want ...
0
votes
2answers
40 views

Tinydns data file change ip with bash

I am using tinydns and need to dynamicly change some ip in data file. I want to use bash script for it. For example data file: +sub1.example.org:282.196.222.245:14400 ...
1
vote
1answer
41 views

Sed to replace/merge line in etc/group

I have a list of users from 1 command - getent group ldap-group|cut -c 32-700 This gives me a list of users in the form user1,user2,user3... I would like to insert this into /etc/group under ...
1
vote
1answer
74 views

iptables arp compare and execute

EXAMPLE: iptables :internet - [0:0] -A internet -m mac --mac-source 48:5D:60:FC:29:B0 -j RETURN COMMIT [root@localhost:~ ] $ arp Address HWtype HWaddress Flags Mask ...
1
vote
1answer
75 views

Wrangling sed to find and reformat login date (or, how to kill idle mosh-server processes)

I have an old method of killing idle mosh-server processes, which doesn't work on my new VPS. Here's the old method, which I run in root's crontab to clean up mosh processes that have been idle for ...
1
vote
2answers
68 views

Long string insertion with sed

I am trying to use this expression to insert the contents of one text file into another after a give string. This is a simple bash script: TEXT=`cat file1.txt` sed -i "/teststring/a \ ...
0
votes
1answer
63 views

sed -i does not work when run with sudo

The file I want to modify belongs to root. I want to change this file with a sudo-er sudo sed -i 's/Accept .* LC_\*$/& GIT_*/' /etc/ssh/sshd_config (trying to append GIT_* to the Accept sshd ...
2
votes
1answer
388 views

How to remove malware code from javascript file using sed

I found the following two different pattern in some hacked javascript files. <!--2d3965--> some code <!--/2d3965--> /*2d3965*/ some code /*/2d3965*/ I am able to remove the first ...
1
vote
2answers
156 views

Deleting inserted content in multiple files on linux server

I often have problem with sites that get hacked. Usualy they end up with inserted script in different files. Is there a way, on linux, to search for this content and automaticaly delte it ? Usualy ...
1
vote
1answer
70 views

sed inline replacement and without having to create a file [closed]

I'm trying to do a replacement inline in a configuration file after defore deploying this file. I looked in the sed documentation but I can't get it working. Even with -e For now I mv into .back file ...
-1
votes
1answer
162 views

sed regexp for replacing xxx in define('DB_PASSWORD', 'xxxx');?

I'm looking for a regexp to quickly replace the password inside the following wp-config file, like so: define('DB_PASSWORD', 'xxxx'); Now the config file has many defines, so it essential to only ...
0
votes
2answers
118 views

Procmail - Replace From with text from within email

I am trying to use Procmail to filter through mail that goes to my ticket channel in WHMCS. It works fine as far as piping goes. But emails from the Zopim live chat module on the site need filtering ...
1
vote
1answer
528 views

How do I replace specific line positions in sed?

I need to be able to use sed (or anything else) to replace a specific line position, I'm Googleing and can't find anything (yet). * UPDATE * this is what I came up so far.. sed ...
0
votes
1answer
75 views

Changing Zone files with sed

I have this dns zone file I was unable to change the resource record type A to CNAME @ IN SOA ns1.domain.com. webdev.domain.com. ( 2006080101 ; serial 8H ; refresh 2H ...
0
votes
2answers
338 views

GREP find and use SED to replace string on all files

One of our old hosted Joomla sites suffered a JavaScript injection, and im going through cleaning it up. The following code was inserted into every .php or .js file: <? #0c0896# echo " <script ...
0
votes
2answers
309 views

sed + how to remove the last string after specific character

how to remove the last string after "." character include the "." character itself implementation can be with sed under Linux/Solaris operation system example of IP address before change ...
1
vote
2answers
48 views

I want to filter out two lines from the output of a program [closed]

I have a command that outputs a bunch of data, but I only want two lines. Grep doesn't work because the lines I want are not next to one another. I can't seem to figure out sed... Help please. :) ...
2
votes
1answer
75 views

How does this sed command work?

I need to print text between two text fragments. I've found such example, that does exactly what I want, but I don't understand how it's done. Googling is difficult because command does not contain ...
2
votes
4answers
1k views

How to escape “/” in a sed command in Puppet script?

In a config file, I'm trying to replace PREFIX=/jenkins with, say, PREFIX=/foobar. On the (bash) command line, this works fine: sed -i.bak s/PREFIX=\\/jenkins/PREFIX=\\/foobar/g /etc/default/jenkins ...
-1
votes
2answers
351 views

linux/solaris insert date & time at the beginning of each line in file

I want to add date & time at the begging of each line in some file I used sed in order to add the date & time before each line in file please advice what I need to update in my sed in order ...
2
votes
3answers
106 views

Replace two characters using one sed command

I'm trying to remove the = and ] characters using one sed command: # echo "A=[A]" | sed s'/[=\]]/ /g' A=[A] Something is wrong with this syntax? I Expect the following results from sed # echo ...
0
votes
1answer
163 views

Regex matching specific details if first match exists, multiline

I'm struggling to get the correct regex to match specifically 'Contact' and 'User-Agent' only if the 'Contact' address matches 10.0.x.x in ~70GB of SIP messages. The SIP message will always contain a ...
0
votes
2answers
314 views

remove non-printing characters

I have a tab delimited text file. When I open the file with vi editor, I can see ^M character (in blue color). This is not part of my data. It got there because the original SQL data had carriage ...
2
votes
2answers
2k views

Using sed to remove both an opening and closing square bracket around a string

I'm running this command in a bash shell on Ubuntu 12.04.1 LTS. I'm attempting to remove both the [ and ] characters in one fell swoop, i.e. without having to pipe to sed a second time. I know square ...
-2
votes
1answer
116 views

linux + count how many digits in IP address [closed]

I write the following syntax (exist in my ksh script) in order to find how many digits I have in IP address IP_address=127.1.1.1 echo $IP_address | sed s'/\./ /g' | wc | awk '{print $2}' 4 . ...
0
votes
3answers
704 views

Remove a sentence which starts with word “mark” and ends with “;”

I am having 100's of files that contain sentence that starts with mark and ends with semicolon(;). eg: mark is driving a car; i need to remove every sentence starts with mark and end with ";" How ...
0
votes
1answer
190 views

perl + sed + remove lines that start with “#”

please advice I have linux and solaris machines, and I need command that work on both OS I use the following perl line in order to remove all lines that start with "#" why perl command not work , ...
-3
votes
2answers
272 views

linux + solaris + delete all characters in file except numbers and dot char [closed]

please advice how to delete all characters in file except numbers and "." Should be implemented by sed or awk or perl ( one line ) or any other idea , so I will add the syntax in my ksh script ...
2
votes
3answers
159 views

linux + match only VALID IP from text file into other file

please advice how to match only the valid IPs ( 255.255.255.255 ) from the file.txt and insert only the valid IP into VALID_IP.txt file ( see VALID_IP.txt for example ) the solution should be ...
0
votes
1answer
71 views

Remove all words that DOESN'T contain a colon [closed]

I have a file with this type of lines: blabla bla:bla whatever what:ever alpha bravo charlie del:ta I only want to keep the words that contain a colon. So the output for the above would be: ...
2
votes
3answers
1k views

How can I easily convert HTML special entities from a standard input stream in Linux?

CentOS Is there an easy way to convert HTML special entities from a data stream? I'm passing data to a bash script and sometimes that data includes special entities. For example: "test" ...
1
vote
1answer
303 views

Writing to /etc/networking/interfaces at boot using sed/awk?

Newbie here, I'm trying to write to an auto-generated /etc/network/interfaces file of a newely provisioned XEN Ubuntu (12.04/10.04/8.04) DomU server at boot time using (currently) sed. The ...
3
votes
2answers
192 views

Extracting a line section of mysql backup using sed

I occasionally need to extract a single record from a mysqlbackup To do this, I first extract the single table I want from the backup... sed -n -e '/CREATE TABLE.*usertext/,/CREATE TABLE/p' ...
0
votes
1answer
95 views

script for changing file dates of postfix Mailbox files

I have a Maildir structure, that got wrongly restored from backup and all files have the file date of the restore instead of when they have been created/received. What would be the best way to ...
2
votes
1answer
3k views

sed replace all tabs and spaces with a single space

I got a string like the following: test.de. 1547 IN SOA ns1.test.de. dnsmaster.test.de. 2012090701 900 1000 6000 600 now I want to replace all the tabs/spaces inbetween the ...
0
votes
2answers
121 views

linux + create host file from CSV file by sed or awk or perl

I have the following CSV file this file defined which Linux machine exist in the system and there ip's my target is to create host file from this file please advice how to create host file as ...
2
votes
2answers
953 views

How can I add a line break before a set of values going into a bash script?

I've got a set of data piping into a bash script. Here's an example of what that data looks like: "foo1": "Miscellaneous text", "foo2": "More text", "foo3": "blah blah blah", "foo4": ...
-2
votes
3answers
2k views

sed replace text - escape characters

I have a mysqldump file in which I want to replace the following text <a href="/tag/ with <a href="http://www.mydomain.com/tag/ but can't find a way to correctly escape all special characters. ...
0
votes
1answer
141 views

Replace Javascript malware code with empty string [duplicate]

Possible Duplicate: My server's been hacked EMERGENCY I have following code in hundreds of my html and js files: ...
7
votes
2answers
832 views

bash sub-string extraction for specified start and end character

For example I have a log file having this entry: [Wed Aug 08 11:39:41 2012] [error] [client 155.94.70.224] ModSecurity: [file ...
2
votes
1answer
188 views

encapsulate text in quotes with sed buffer

I need to do a search and replace to encapsulate a variable string in single-quotes (php object notation into php array notation) such that the following block: $my_trip->trip_id = ( ...
1
vote
1answer
131 views

sed replace inside shell file

I have a shell file which needs to perform a replace of some text in a php file. The line that needs replacing is: $database = $db."_db"; The actual sed command needs to contain a variable so not ...
0
votes
3answers
182 views

How to join a variable number of lines

I have a file with Feature names and a variable number of usernames below: Feature1 user1 user2 Feature2 user3 I'd like to be able to move the usernames to the same line as the Feature name ...