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

learn more… | top users | synonyms

2
votes
4answers
4k 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
129 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. ...
1
vote
2answers
847 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
161 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
129 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
657 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
137 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
216 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
619 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 ...
2
votes
1answer
679 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
168 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
98 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
313 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
853 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
82 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 ...
9
votes
5answers
1k 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
2k 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
771 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
396 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
90 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
126 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
104 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
446 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
155 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
167 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
423 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 ...
3
votes
1answer
1k 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
3k 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
597 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 ...
0
votes
3answers
178 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
96 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
386 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
709 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.
3
votes
3answers
3k 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
266 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
107 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
328 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
305 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" ...
3
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
114 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
330 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 ...
1
vote
1answer
245 views

Moving parts of a string with a Regex in sed

I am trying to replace, input.output.roomMAX[0] to input.output.room[0].MAX input.output.roomMAX[1] to input.output.room[1].MAX input.output.roomMIN[variable] to ...
5
votes
3answers
440 views

Search for files with more than one term (grep, awk?)

I am using a command like this to find files with the word 'term' in them: grep -l term * But I now want to be able to find files which have two different words in them (let's call them termA and ...
1
vote
1answer
1k views

Using a table or script in sed to replace many special characters with escape characters?

If u want replace special characters using sed you can use different ways, but the problem is you have to replace many (100+) special characters with escape characters in many files. so it needs: ...
3
votes
2answers
5k views

Replace special text with sed?

I'm using CMD on Windows Xp to replace special text with Sed. I'm using this command for replace special characters like $ or * : sed -i "s/\*/123/g;" 1.txt But how command must i use to replace ...
0
votes
1answer
115 views

how to get access to environment variables from output file

I want to get variables from a output file specific location,and input file format as below: log1.txt format: [v] Output Data ...
2
votes
1answer
384 views

bypass character limit in Sed and the replacement / character?

I'm Using windows Xp. I want to replace a word of length 200,000 characters and CMD has problems (the input line is too long). With Linux, does the terminal have same length problems? If I replace ...
3
votes
1answer
949 views

Finding and deleting lines from all files recursively

I have managed to grep the occurences of a keyword by using grep "KeyWord" . -r -n -i -I but, the occurences of the KeyWord are too large. I just want to delete all the lines containing that word. ...