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

learn more… | top users | synonyms

0
votes
1answer
93 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
132 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
107 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
493 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
167 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
186 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
504 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
835 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
313 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
104 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
447 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
889 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
298 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
127 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
370 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
325 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
358 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
319 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
500 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
116 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
429 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
641 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
163 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
66 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
79 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
376 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
315 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
910 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
189 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
286 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///, ...
2
votes
3answers
349 views

How to substitute multiple lines between delimiters

Given the text example: .... text ,.. {{{python string1 = 'abcde' string2 = '12345' print(string1[[1:3]]) print(string2[[:-1]]) }}} .... text ,.. The [[ and ]] also appear outside of {{{ too. ...
1
vote
1answer
500 views

Find/replace underscored words to camelCase words using regex?

I have a ton of text files that are tagged with underscore-connected words like @some_text, but I would like to convert those to tags in camel case, like @someText. How can I use regex (either in vim ...
8
votes
5answers
12k views

How to get the pid of a running process using a single command that parse the output of ps?

I am looking for a single line that does return the pid of a running process. Currently I have: ps -A -o pid,cmd|grep xxx|head -n 1 And this returns the fist pid, command. I need only the first ...
2
votes
2answers
1k views

perl - translate sed to perl

The following command work fine on Solaris ( delete line only if last character is ":" ) sed -e '/:$/d' < foo > foo.new how to do the same in perl ? ( the reason for that because I not want ...
11
votes
3answers
2k views

Substitution in text file **without** regular expressions

I need to substitute some text inside a text file with a replacement. Usually I would do something like sed -i 's/text/replacement/g' path/to/the/file The problem is that both text and replacement ...
1
vote
1answer
1k views

How can I use sed to modify a line of a configuration file?

My configuration file has the following format [general] setting1=true setting2=value2 [ssl] setting1=sadfsdf setting2=sdfadsfkljasdf How would I change setting 1's value to false? If I could just ...
1
vote
3answers
354 views

sed: replace each occurence of 4 spaces (at beginning of a line) with 2 spaces

Say I have this (puppet) file with an indentation of 4 spaces (I have a bunch of them that I have to process): # init.pp class hardwareid ( $package_name = $hardwareid::params::package_name, ...
2
votes
1answer
2k views

Add character at certain position in line

I've encountered the following problem: I need to add space at certain position in each line, to transform data from ATOM 1 HT1 GLY 5 10.346 30.927 130.252 0.00 0.00 to (by adding ...
1
vote
3answers
655 views

How do you parse out words from a file?

Hi let's say I have a file that looks like this <jack, john. ................ ,joe ..........Jen.. >Tom Edwa4rd 4Tim Richard How do I turn this into a clean list like jack John joe Jen Tom ...
1
vote
1answer
875 views

Replace a block of numbers in sed

I've been fiddling with this for a while now and can't seem to figure it out. What I'm trying to do is replace all numbers in a file with a single #. Sounds simple, and it should be, but I can't get ...