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
0answers
20 views

Find line within file matching pattern and make a substitution [migrated]

I'm trying to simplify my life here but I'm stuck. I have a file containing multiple lines. Each line has a user and a number. I'd like to know a bash one-liner to search for a user and change the ...
-2
votes
2answers
38 views

how to replace one url with another using sed inplace replace in multiple files?

As you can see in the script example down there, I'm trying to find and replace (inplace replace) a string which is part of an URL with another string (url part) within ALL files found with that ...
0
votes
1answer
61 views

Sed - extract only parts of file with certain timestamps

I work with log files on a daily basis. I have been using sed to accomplish my goal of extracting certain lines of data between to time stamps. For example, I use: sed '/20150720 15:06:00/,/20150720 ...
0
votes
3answers
161 views

sed replace unix path with variable that contain another unix path [closed]

I need to replace Unix path via sed with variable that contain another unix path in a bash script Example: another_unix_path=/another/unix/path sed -i 's/ \/some\/path\/file.txt/ ...
2
votes
1answer
43 views

how to get the desired value in bash shell from the lshw output?

I want to extract the info from lshw output where it says: -cpu product: ...... I want only the product info of this -cpu. How can I do that with awk or sed?
1
vote
1answer
47 views

ssh remote command execution quoting

I found this solution that works for me, but I don't understand how it does work given that the sed command encloses its own parameter in single quotes, and the whole ssh command is also passed in ...
1
vote
1answer
43 views

How to using sed to change the last character from a match line

How to using sed to change the last character from a match line ? Exemple: /etc/network/interfaces auto eth0 iface eth0 inet static address 150.0.3.50 netmask 255.255.255.0 ...
0
votes
0answers
36 views

Mysql sed error

I upgraded mysql from 5.5 to 5.6 in Debian 7 Wheezy box via apt-get command and all seems fine, but when I restart mysql, I get: [info] Stopping MySQL Community Server 5.6.23. ...... [info] MySQL ...
2
votes
2answers
308 views

Split large log file WITHOUT keeping the original (splitting in-place)

I have a 226GB log file, and I want to split it up into chunks for easier xzing. Problem is I only have 177GB of space left in my workable space. Is there a way to split a file in half or into N ...
-2
votes
1answer
448 views

How to insert text from a file into another in bash [closed]

The content in fileA is: Here’s the ip list. ip: 2.2.3.4 ip: 2.2.3.5 ip: 2.2.3.6 ip: 2.2.3.7 The content is fileB is ip: 1.2.3.4 ip: 1.2.3.5 ip: 1.2.3.6 ip: 1.2.3.7 How to use sed command or ...
1
vote
1answer
78 views

How to substitute a string from an awk result?

I have a JSON file which contain multiple occurrence of replaceme. I only want to substitute an occurrence based on a specific string found a few line above. E.g., [...] "title" : { ...
2
votes
2answers
87 views

How can I use Puppet to Enforce Local Group Membership?

Cross posting this from Ask@PuppetLabs. (There simply isn't enough traffic there.) I've seen a number of examples for adding users to %wheel with Augeas. These are all variations of the same thing; ...
0
votes
3answers
402 views

Modify config file settings from bash [closed]

I need to modify a config file from a bash script, changing the values of particular settings. I need to make the change using common Linux tools (sed/awk/tr/etc.). The config file can have ...
0
votes
2answers
68 views

How to use a variable in a sedscript

I set a variable in a shell script I then call a sed script and in the sed script I use the variable That does not seem to work and I needed help on how to achieve that Following works at the ...
0
votes
2answers
102 views

Replace date in epoch (seconds) format to normal in a log file

I am on a ubuntu machine trying to read from log files and found the logs contain date and time in epoch format(seconds). How can I convert these dates in numbers into any readable format from command ...
-1
votes
1answer
541 views

sed, replace in linux http://cdn1 with https://cdn1

I want to replace http://cdn1.domain.com with https://cdn1.domain.com in 200 .html files and I don't know how to do that with sed. Can somebody help me with this? sed -i ...
0
votes
1answer
195 views

sed comand - remove virus from wordpress [duplicate]

I have malicious code in every php file. This malicius code is auto paste at the beginning of file. I want to remove this with UNIX command from console. This is malicious code: <?php ...
0
votes
1answer
2k 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
41 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
235 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
134 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
808 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
103 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
112 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
3answers
78 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
112 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
140 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
130 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
128 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
167 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
557 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
161 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
118 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
445 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
299 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
2k 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
167 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
478 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
2k 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
63 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
83 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
3k 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
706 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
914 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
248 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
620 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 ...
3
votes
3answers
8k 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 ...
-3
votes
1answer
144 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
2k 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
352 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 , ...