"sed" ("stream editor") is a Unix utility that parses and transforms text files.

learn more… | top users | synonyms

0
votes
1answer
580 views

replace long text with special characters with sed

I am using sed in unix to replace some text with special characters in a file. I google it and find the following command sed 's/from/to/g' file.txt here 'from' is the original text being replaced, ...
0
votes
4answers
118 views

Simple script parsing text, what is wrong here?

I'm a big user of https://www.grc.com/passwords.htm to get strong passwords. However, having to go to the site and manually copy the password every time gets old fast, so I decided to do a little ...
0
votes
1answer
2k views

How to append text to a specific lines in a file using shell script?

I have a text file (file.txt) having content something like: foo1 3464 foo2 3696 foo3 4562 It contains the process and respective PID. Using shell script, I want to append a string (running/not ...
3
votes
3answers
69 views

merge pieces of file together

I have a directory tree of files I need to loop through and reformat the lines. can I do this with sed with some combination of find? for each file, I'll need to adjust the text in the file from ...
7
votes
2answers
2k views

Edit first line of large text file

I have a huge text file, far too big for the whole thing to be paged into memory. All I need to do with this text file is edit the first line (its a CSV file and I need to alter the titles). Is there ...
3
votes
2answers
4k views

use sed to replace nbsp, 160, Hex 00a0, Octal 240, non-breaking space

I am having some problems with config files which have the non-breaking space chars in them. How should I specify that character with sed so I can replace it with a space. sed -n 's/ / /g' ...
0
votes
1answer
97 views

Get original sed back on my Mac

I replaced sed with the GNU version on my Mac. I thought I made a backup of the original (BSD version), but apparently I didn't, and now I need it back. Can someone help me?
2
votes
4answers
7k views

Using sed get substring between two double quotes

I have a file xyz... rsync: "/home/path/to/file": Permission denied (13) rsync: "/home/path/to/file1": Permission denied (13) rsync: "/home/path/to/file2": Permission denied (13) rsync: ...
1
vote
2answers
176 views

Parsing two input files and comparing line existence

I need to take two text files and check to see if a line that exists in File A doesn't exist anywhere in File B. Each line in File A that does not exist in File B should be copied to an output log. ...
2
votes
2answers
3k views

sed regex digits

I'm trying to use sed to substitute all the patterns with digits followed immediately by a dot (such as 3., 355.) by an empty string. So I try sed 's/\d+\.//g' file.txt But it doesn't work. Why is ...
2
votes
1answer
181 views

Delete first lines from a Unicode html file

I have an HTML file that is in UTF-8 format and I want to remove the first five lines from it. I've tried using sed but it doesn't work in this case: sed "1,5d" Result.html>small2 It actually ...
2
votes
1answer
172 views

Grep the whole body of a function

Supposing I know that someFile.php contains the definition for someFunction(). How would I go about displaying the whole body of the function in stdout? If I know that the body is 10 lines long then I ...
2
votes
4answers
934 views

How do you remove all occurrences of values in one list from another list?

I have a list of symbols such as... wer sfe efo How do I remove all instances of these (unique) symbols from another list of (non-unique) symbols? So in the following list, the lines starting ...
3
votes
1answer
159 views

Parse by Control Characters

I am trying to parse the output of a command that expects to be writing to the screen. It has data separated by move-to-origin control sequences (for the VT220, ESC[1;1H). I only need the last part ...
2
votes
2answers
280 views

Is there a UNIX command that can replace an XML element? (Like a sed for an XPath?)

Is there a pipe-friendly program that takes: An XML document An XPath expression indicating the target element(s) The desired replacement ? Something like sed but knowledgeable about XML ...
1
vote
0answers
14 views

FTP over'd image files with transfer-type: ASCII; possible to revert? [duplicate]

Possible Duplicate: Recovering corrupted files uploaded in wrong FTP mode undo effect of ASCII ftp transfer I've downloaded hundreds of files from a Drupal install using FileZilla. ...
0
votes
2answers
814 views

using sed to print next line after match

I came across various examples on printing next line after a match, that use awk and sed. I'm using it in my code and it works fine. Now I want to use a variable instead of a hardcoded value for the ...
3
votes
1answer
881 views

grep, xargs, sed to clean up PHP eval hack

I'm attempting to use the commands found on http://devilsworkshop.org/tutorial/remove-evalbase64decode-malicious-code-grep-sed-commands-files-linux-server/55587/ to clean up a PHP eval based hack on a ...
2
votes
1answer
236 views

sed stdin faster than reading from file?

I'm trying to determine if sed is faster reading from stdin (with shell redirection < ) or by specifying the file from which sed should read. I didn't find a definitive answer on Google. Which is ...
0
votes
1answer
102 views

Can not understand this script

Can someone help me understand this script? It is from sysconf_add and I am new to scripting. I need to do something similar. function add_word() { local word=$1 local word_quoted=$2 ...
0
votes
1answer
424 views

remove white space before delimiter with sed

I have data of the following format that I want to input into LibreOffice Calc: data | num | num | num | num For some reason LibreOffice does not think the string "3214 " is a number by default ...
0
votes
1answer
1k views

solaris 10 + display 2 lines after match by grep?

how to match string , and display the two line under the string for example ( I want to match the "manufacture" string and display the two lines after cat ima.conf # the manufacturer or driver ...
1
vote
2answers
1k views

How to extract e-mail or domain from mixed data file in linux

File content: 17541 From Email subscription@test.com Inbound Policy Manager Envelope Analysis Profiler 17541 From Email subscription@yahoo.com Inbound Policy Manager ...
-1
votes
1answer
87 views

using sed, how to change the text on line seven to read seventh?

using sed, how to change the text on line seven to read seventh? Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA 83755:11/12/56:20300 Betty Boop:245-836-8357:635 Cutesy Lane, Hollywood, CA ...
13
votes
5answers
3k views

How to mass prepend text to file names?

Lets say I have a directory full of .md files all named various things. Lets say I wanted to prepend "text" to the front of each file name. So for example: file a.md, b.md, and c.md would become test ...
1
vote
5answers
3k views

How to grep column after second pipe

Example: 3|100|test@test.com|0|0|6:1,10,11,12,13,2,3,4,5,6,9|7:1,10,11,13,16,2,4,5,6,9| Expected view after grep: test@test.com
3
votes
2answers
1k views

sed Command on BusyBox expects different syntax?

I hope I phrased the question correct. I have a script that makes use of 'sed' a lot. It works great on my ubuntu with the GNU 'sed'. But when I try to run it on BusyBox it fails. Is there a way to ...
-1
votes
1answer
502 views

Using sed, how can I delete all blank lines? [duplicate]

Possible Duplicate: How to remove blank lines in .txt files Using sed, how can I delete all blank lines? Input file: Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA ...
0
votes
1answer
96 views

Using sed, how can I remove lines with salaries ending 500?

Using sed, how can I remove lines with salaries ending 500? Input file: Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA 83755:11/12/56:20300 Betty Boop:245-836-8357:635 Cutesy Lane, ...
2
votes
1answer
145 views

Using sed, how to print the contents of the file with the last names and first names reversed?

Using sed, how to print the contents of the file with the last names and first names reversed? Input file: Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA 83755:11/12/56:20300 Betty ...
0
votes
1answer
117 views

How to change a birthday to a certain date in matching lines

Using sed, how would I change Popeye’s birthday to 11/14/46? Assume you don’t know Popeye’s original birthday. The input filename is datebook, as follows: Arthur Putie:923-835-8745:23 Wimp Lane, ...
0
votes
2answers
572 views

Using sed, how to print all lines that match a certain date?

Using sed, how to print all lines where the birthdays are in November or December? Assuming input file name "datebook" as follows: Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA ...
0
votes
3answers
181 views

Use Sed/Awk to fix faulty SRT files

Recently I downloaded some badly formated SRT files, having the time format messed up as HH:MM:SS:XXX whereas it should be HH:MM:SS,XXX The main problem now is to replace the third colon with a ...
2
votes
3answers
210 views

How to use Sed to edit text in .srt file?

I have a problem with subtitle file(.srt). It doesn't work. And i want to add some parameter to many lines of text with Regex in Sed program. changes from this pattern: 00:00:00 --> 00:00:06 to ...
3
votes
2answers
591 views

Using sed to Download ComboFix automatically

I'm trying to write a shell script to grab the dynamic URL which ComboFix is located at at BleepingComputer.com/download/combofix However, for some reason I can't seem to get my regex to match the ...
4
votes
1answer
2k views

How do I parse file paths separated by a space in a string?

Background: I am working in Automator on a wrapper to a command line utility. I need a way to separate an arbitrary number of file paths delimited by a single space from a single string, so that I may ...
0
votes
2answers
6k views

How to use sed to replace a pattern at the end of each line in a file with fixed text?

I want to compare two files of around 40 MB of comma separated values with lines like this: hstar,default,"T9883Z ",0d59,c801,7332,5,20120914,4.343618767 For the two files, the last entry which ...
4
votes
2answers
1k views

sed: replace first occurance of a string in every line

Imagine I have a file like this: INSERT INTO table VALUES('1','<p><em>The lazy fox jumps again</em></p>bunch of other html<p><em>Is the lazy fox ...
1
vote
3answers
569 views

How to search file for matching whole lines?

I have a command which sends to stdout a series of numbers, each on a new line. I need to determine whether a particular number exists in the list. The match needs to be exact, not a subset. For ...
0
votes
3answers
112 views

Symbol 001E in a box on a Linux terminal

When reading a Windows log file in a Linux terminal, I see a strange symbol “001E” How can I replace it by space? Maybe something like sed -e 's/010e/ /'
4
votes
3answers
547 views

sed: replace only the first range of numbers

Imagine I have an input file like this: INSERT INTO video_item_theme VALUES('9', '29'); INSERT INTO video_item_theme VALUES('19', '312'); INSERT INTO video_item_theme VALUES('414', '1'); And I wish ...
2
votes
3answers
1k views

sed: delete all but the last X lines of a file

It can be done with other tools, but I am interested to know how can I delete all but the last X lines of the file with sed.
4
votes
3answers
4k views

sed: delete text between a string until first occurrence of another string

Imagine I have something like the following text: The quick brown fox jumps in 2012 and 2013 And I would wish to delete the part from "fox" including the four numbers but only in the first ...
2
votes
3answers
349 views

Adding text to the beginning and end of a number of files?

I have a number of files in a directory hierarchy. For each file, I'd like to add "abcdef" to the beginning, on its own line, and "ghijkl" to the end, on its own line. For example, if the files ...
1
vote
1answer
156 views

Delete specific line from hosts

I want to delete specific line from hosts file in my home dir: ~$ echo "193.10.1.1 localhost" >> hosts ~$ echo "127.0.0.1 localhost" >> hosts ~$ cat hosts 193.10.1.1 localhost 127.0.0.1 ...
1
vote
1answer
408 views

Using vim/sed how do I replace the string “___COPYRIGHT___” with another string

I am having issues with sed/vim using the s/replace this/with this command. Here are some screenshots to show the issue. How do I match this string and replace it with what I want?
1
vote
1answer
346 views

Using find and sed to rename several subfolders

What I am trying to do is rename folders that are anywhere in the current tree, not neccessarily directly in the working directory. What I need to do is: "A 1" becomes "A 01" "A 2" becomes "A 02" ...
4
votes
1answer
1k views

sed weirdness, unmatched {

I'm trying to use the r (read command to append the contents of data2 to data. I want to append the contents after the line containing 'two'. I want to delete the line containing 'two'. But I've hit ...
2
votes
1answer
117 views

can sed remove every line that contains 'foo'?

I read somewhere that: sed -n -e '/foo/d' myinputfile.txt would remove all occurences of 'foo' from myinputfile.txt. However this does not seem to work for me. I am a sed noob and cannot seem to ...
2
votes
2answers
409 views

How to remove three consecutive line feeds in a Makefile rule?

I need to search for and replace three consecutive newline characters in an input file and filter them out of an output file for a makefile rule on Centos 4. I am using GNU sed v4.1.2 and GNU make ...