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

learn more… | top users | synonyms

2
votes
1answer
212 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
101 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
373 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
86 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 ...
12
votes
5answers
2k 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
945 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
461 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
94 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
134 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
109 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
511 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
172 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
195 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
537 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
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
4k 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
960 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
417 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
108 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
481 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.
3
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
324 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
139 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
394 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
336 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
374 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
353 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
533 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
6k 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
117 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
440 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
1k 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. ...
3
votes
1answer
670 views

Replace path on Windows with sed?

I'm trying to get rid of all paths that include the current directory, so I did my_command | sed "s/%CD%//ig" in the command prompt, but it didn't work -- everything came out just like before. How ...
3
votes
3answers
164 views

unix command to verify span of word in text

What unix command(s) can I use to determine the line span that a word appears in text? The "span" being equal to the line number of the last instance of a word minus the line number of the first ...
4
votes
1answer
1k views

Where does Macports install GNU sed when I install coreutils port?

Where does Macports install the GNU sed when I install coreutils port? I want to use GNU sed instead of BSD sed on Mac OS X.
1
vote
2answers
66 views

Understanding !d command in sed with respect to saves

I have a directory of tab-delimited text files and some have comments in the first few lines that I would like to delete. I know that the first good line starts with "Mark" so I can use /^Mark/,$!d to ...
2
votes
1answer
69 views

Fixing a sed Command to Include Characters Conditionally

How can I improve pwd | sed -e 's/.*\/\(.*\)\/\(.*\)\/\(.*\)/...\1\/\2\/\3/' to only return the ellipsis if pwd is greater than three levels deep? The goal is to avoid ...home/example/foo, but still ...
2
votes
1answer
80 views

sanity check file to produce binary answer

What Unix command(s) can I use to determine the existence of each of several words and the non-existence of each of several words which will produce a binary answer? For example: I want to be sure ...
0
votes
1answer
383 views

IP Address dotted decimal to /8 or /16 notation using bash,sed or awk?

I have an input file that contains a list of ip addresses and the ip_counts(some parameter that I use internally.)The file looks somewhat like this. 202.124.127.26 2135869 202.124.127.25 2111217 ...
1
vote
1answer
348 views

Use OS X's sed in a script to find a string and append a line beneath it including a newline character

I've learned that the BSD version of sed included with OS X doesn't provide an intuitive way to add newlines. I've found a few notes about it, but I don't understand yet, how to extend the examples ...
1
vote
3answers
977 views

Delete lines with matching pattern after the first line with sed

I would like to delete every line that contains a pattern after the first line (the pattern is /^country\t/). I can delete every occurrence with sed '/^country\t/d' in.txt > out.txt, but I would ...
1
vote
1answer
197 views

create multiple files from single text file based on headings

I have what I think is a really simple problem to solve (preferably with OS X / *nix terminal tools rather than windows command line). I have a manuscript formatted in markdown with # (H1) denoting ...
0
votes
1answer
297 views

Pattern matching gnmap fields with SED

I am testing the regex needed for creating field extraction with Splunk for nmap and think I might be close... Example full line: Host: 10.0.0.1 (host) Ports: 21/open|filtered/tcp//ftp///, ...