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

learn more… | top users | synonyms

2
votes
2answers
34 views

How to find the common paths from a list of paths/files

Prelude: Given a sorted input of a list of paths/files, how to find their common paths? Translating into tech term, if feeding the sorted input from stdin, how to pick the shortest proper prefix ...
0
votes
0answers
13 views

Bootstrap pkgsrc on macosx (10.9) error

I am trying to bootstrap pkgsrc-2014Q2 on OS X 10.9. The script complains: cd /Users/tiramo/Downloads/pkgsrc-2014Q2/bootstrap/work/wrk/pkgtools/bootstrap-mk-files/work/bootstrap-mk-files-20140516; ...
0
votes
1answer
24 views

Is \d equal to [0-9] in sed?

7 00:00:30,008 --> 00:00:30,066 by line 8 00:00:31,038 --> 00:00:34,050 or later in the nineteen seventies it was usually a 9 00:00:34,005 --> 00:00:38,634^M video consul but the council was ...
0
votes
1answer
35 views

How to pass output of command to sed

My sed command in #Update key in config file. does not get the contents of the variable $GETKEY Someone help me? # Get key from output of the website. GETKEY=`wget https://www.badips.com/get/key ...
0
votes
0answers
19 views

binary substitution in (audio)streams with bbe or sed

I try to do some stream manipulation with webradio streams. Goal is to use a pattern in triggerfile to substitute some seconds of the instream to silence in the outstream I found bbe to possibly fit ...
0
votes
2answers
48 views

Increment version text stored in a bash script file

I have a bash file and I want to store a version text in it (preferably "echo version 1.0.1" so that it automatically prints out its own version when executed) I am trying to make a command group ...
0
votes
1answer
45 views

sed: What does exit code 2 mean?

Case I am trying to replace all occurrences of <value>*</value> into <value>file:\\</value> in a designated file test.txt. I work on Windows and use sed I have installed with ...
1
vote
1answer
31 views

Run sed as a one-off ssh command

I would like to substitute a string with another in a file on a server of mine. I've tried doing this: ssh $REMOTE_HOST sed 's|export ${KEY}=${VAL}|export ${KEY}=${NEW_VAL}|' "$ENV_FILE" And a ...
0
votes
1answer
36 views

Replace negative values in a file with zeros

I want to replace all negative values in a file with zeros. How can I do this in awk? I tried with gsub but gsub(-*, 0) doesn't work... Any ideas? My "code" is awk '{gsub($(!/-/),"0",$2); print $1 ...
3
votes
3answers
56 views

Sed replace only in even numbered lines of a file when replace commands are written in a file

I have all the replace commands in a file (say replace.sed) and i use it with -f flag of sed (sed -f replace.sed InputFile). But now i ran into a condition where i need to apply these replace rules ...
1
vote
1answer
38 views

Non case sensitive search case sensitive replace

How do I search/and replace like this using sed or another tool FOO => BAR Foo => Bar foo => bar That is: Look for foo regardless of case, and replace with the same case pattern. One ...
2
votes
1answer
93 views

sed, insert file before last line

The following inserting file method for sed used to be working, even before last line, but not any more. Is it a bug in the current sed? Demo of inserting file method with sed: mkdir /tmp/test ...
0
votes
0answers
14 views

How to colorize the output using sed - no GNU tools available

I'm using a short alias in my .profile file to colorize the output of the sdiff command, just to make it easier to spot differences. The alias is like this: alias color_diff="sed 's/[|< |> ...
0
votes
1answer
22 views

Escape brackets when using SED

I would like to replace the value varchar(36) with char(36) in a file by using sed. I am trying with sed -i ’s/varchar(36)/char(6)/g’ calls_contacts.sql But the command does not execute. What am I ...
0
votes
1answer
50 views

How to replace a line in an xml file with a set of lines stored in a variable or file using unix commands?

I have a xml file in which the line that needs to be searched is: SEARCH='<?xml version="1.0" encoding="UTF-8" standalone="no"?><SSC>' This searched value needs to be replaced with ...
2
votes
2answers
135 views

sed error when launching terminal on OS X

I get these error messages when launching bash or zsh in standard Terminal.app or iTerm2 sed: 1: "\#^system_type=# { s#^s ...": extra characters at the end of p command sed: 1: "\#^system_type=# { ...
1
vote
2answers
59 views

Adding text to the end of multiple files, minus one line( Adding return 0; at the end of each program in C)

I have a bunch of C programs from K&R and of course, no return statement. I was wondering if there was a way to cat to the end of each file (except one line before the end, so EOF - 1) the ...
0
votes
0answers
29 views

How to call “sed” on PDF files

I am able to find text on PDF files using pdfgrep. How can I sed them? I just want to change a pattern of text and I don't think I need a editor for that. Or do I? How can I achieve that?
0
votes
1answer
27 views

How to use sed to examine the line without specific content?

I made a toy file named toy, its content is like: aaa bbb My first idea is to use: sed -n '/[^a]/ p' toy bbb it prints out bbb, but when I added bb ab to the end of toy file. I found it lose ...
-1
votes
2answers
66 views

add line number after matched pattern in vim

I have raw sequences and I have to convert it to fasta format. so reads are like this: CTACGGTGTGCTCTTCCGATCTGACTATG AGTTGGTGTGCTCTCCCGATCTCGCTCCCTC GTGAGGTGTGCTCTTCCGATCTCCGGCAGTGTGCT and i want ...
4
votes
2answers
111 views

shell script to replace a keyword in a file with the contents of another file

I'm to create a .sh to replace a specific keyword in a file using the contents of an other file. template.html contains a unique string "PLACEHOLDER" it must be replaced with the contents of file ...
2
votes
4answers
59 views

Extract lines based on long list of line numbers

I have a long list of line numbers (35389208) that I do not want in my file. By line number I mean the line in my file (e.g. line 277). My list of line numbers I do not want looks like: 277 278 279 ...
1
vote
1answer
158 views

Apache as Proxy replace the html code/tags/text

I configured my apache2 server as a proxy server. I added some filters to my proxy.conf file to change the text (html source code) of the websites. Example code: ExtFilterDefine foodo mode=output ...
3
votes
1answer
108 views

Using sed with parallel gives empty output when redirecting to file

I'm using the zsh shell. I am trying to use sed to substitute some text in many files, using parallel to speed up the process. When I tested this on one file and let the command output go to stdout I ...
0
votes
1answer
75 views

using sed to replace 1 line with a multi-line variable in ksh

I have the following text in a file: XXXX NNNN YYYY NNNN ZZZZ NNNN I want to replace the NNNN to make it look like this: XXXX NNNN DUTY FORECASTER: YYYY NNNN DUTY FORECASTER: ZZZZ NNNN ...
1
vote
2answers
355 views

Properly escaping forward slash in bash script for usage with sed

I'm trying to determine the size of the files that would be newly copied when syncing two folders by running rsync in dry mode and then summing up the sizes of the files listed in the output of rsync. ...
0
votes
1answer
69 views

GnuWin32 sed how can I search and replace quotes? Win7 UK

Getting really weird behaviour with sed in Win7: Manual says surround substitute command with single quote (') - rejects, only allows double quote ("). Plus I want to change double quote in a file to ...
0
votes
2answers
119 views

Search, match and replace 1st column with a value using sed

I would like to get some advice using sed on how to replace value1 on first column that matches with value2: value1 = 9999 value2 = 02a-ResetFlag.sh Data File ---------------------------------- 0500 ...
1
vote
2answers
75 views

Replacing every 10th pipe with new line in unix

Lets say I have fields: name, number, id I have a data file: name1|number1|id1|name2|number2|id2...etc I want to replace every 3rd pipe with a new line or '\n' so I get: name1|number1|id1 ...
1
vote
2answers
39 views

How do I print multiple sections in a text file?

I have a text file looking something like this: *FILESTART line_a line_b line_c *INCLUDE file_A.key file_B.key *INCLUDE file_1.key file_2.key file_3.key *SOMETHING_ELSE line_x line_y line_z *END I ...
1
vote
1answer
22 views

Print every line but conditionally only fragments for some lines

I have a text file that looks like this: rno-miR-344-5p miRPlus_11239/mmu-miR-383/rno-miR-383 hsa-miR-301a/mmu-miR-301a/rno-miR-301a ...
0
votes
1answer
34 views

Filtering data with sed

I need a help. I have a file like sometext line 1 sometext line 2 SU0000 ID ID ID sometext line 3 sometext line 4 sometext line 5 sometext line 6 SU0000 ID ID ID sometext line 7 sometext line 8 ...
0
votes
0answers
35 views

Tmux status sed output different from cli

I've been looking at this for a while now, but I cannot find a reason. When I run the following in a cli, it works as expected: $ uptime | sed "s/.*average: \(.*\), \(.*\), \(.*\)$/\1 \2 \3/g" 0.65 ...
0
votes
1answer
59 views

SED: syntax error at script.pl line 19, near “;$'”

I am using this command to delete multiple occurrences of a line in my script and it just works fine when I run it on the command prompt. However when I use this line in my perl script it throws an ...
0
votes
1answer
76 views

Regexp based editing of content in large CSV files [duplicate]

I wanted to remove certain pattern of contents based on a regex from csv file which is very large in size containing 100,000+ records, how is it possible via windows commandline? I also have sed and ...
0
votes
2answers
63 views

Removing Nested LaTeX Tags with Regex

How would I use regex (such as with sed) to remove all \index tags that occur inside any \index tags? For example, a nested mess like this: \index{Test\index{test\index{test}}ing One\index{one} ...
2
votes
1answer
151 views

Use perl to do multi-line replacement [closed]

I have to do some replacements in many *.c files. I want to do the replacement like this: original: printf("This is a string! %d %d\n", 1, 2); result: print_record("This is a string! %d %d", 1, 2); ...
0
votes
1answer
21 views

Replace '-' char using sed

I have a text file, quite similar to this one: JACK BLACK 123456 -1245368 - BRIDGET RED 1245 548425 + JOHNNY HOMUSS 55482 -4325 - I wanted to use a sed command ...
0
votes
1answer
30 views

Sed is not Interpreting Pipes Correctly

OK, this is hard to explain, so I will give a reproducible example: I have a text file test.txt contains the line: somesetting-parameter /an/old/path I want to replace it with a path I can get via ...
-2
votes
2answers
62 views

Trying to count and print song file names using awk

RANK NAME BAND YEAR GENERE DOMESTIC/INTERNATIONAL 206:Reach Out, I'll Be There:The Four Tops:1978:Pop:3/2 207:Bye Bye Love:The Everly Brothers:1950:Classic:3/2 ...
1
vote
1answer
85 views

Zsh autocomplete function with sed

I'm struggling to write an ZSH autocomplete function. My goal is to autocomplete ta's and tk's first argument with the projects listed in tmux list-sessions and tmuxinator list. Here's what I have so ...
1
vote
3answers
99 views

Can anyone explain why this pattern matching is not working using sed

Trying to print out specific times of logs based on recommendation from this thread from super user. I am not sure why my patterns are not being matched by sed. I have the sample date and time I am ...
1
vote
1answer
51 views

Matching only numbers that come in numerical order

I have numbers in [.] indicating the page number of an orginal printed document I am transcribing. However, the document also contains other numbers in [.] that do not correspond to page numbers. For ...
0
votes
1answer
69 views

Bash alias with Sed not working

Does anyone know why this alias isn't working? alias tailsed="tailf error.log | sed -e 's/\\n/\n/g' -e 's/\\t/''/g'" I've tried replacing the single quotes with doubles so that it's like: alias ...
0
votes
3answers
57 views

sed rename files moving numbers to end of file

I have a directory that contains several files with the following pattern. 1953-MADAMA BUTTERFLY 1953-MADAMA BUTTERFLY_001 I'm trying to bath rename them to achieve the following: MADAMA ...
0
votes
2answers
140 views

How can I create a sed command line from diff?

I'm aware that diff -e can output an ed script. And my understanding is that ed and sed share their approach, but that ed is interactive, and sed is for streams. What I would like to do is take the ...
0
votes
2answers
107 views

Installation of Git on Debian 7.4 fails

I tried to install Git (from source) on Debian 7.4, but the installation fails with the following message: Writing perl.mak for Git Writing MYMETA.yml * new perl-specific parameters GEN ...
1
vote
1answer
102 views

sed can't get string match

For the life of me I can't seem to get this to work, no matter how many different combinations I try. I'm trying to recursively search a folder for php files containing a particular string and replace ...
2
votes
1answer
90 views

sed: Removing \r\r before \n in a very large file

I have a corrupted disk image file (about 27 GB) in which before all \n characters \r\r was inserted. I want to remove these \r\r before all \n. I tried with awk: awk '{ sub("\r\r$", ""); print }' ...
2
votes
2answers
162 views

sed: How can I replace \r\r\n?

In this question on stackoverflow it is explained how one can replace a newline character using sed. My problem is that I want to replace the character sequence \r\r\n with sed. Can somebody help me ...