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

learn more… | top users | synonyms

0
votes
0answers
18 views

delete all values in a .csv file besides the name “EC_Customers” and “EC_Leads”

I have a .csv file that has a column for contact tags. In this column, I have a whole bunch of separated tags. I want to delete all of the tags besides "EC_Customers" and "EC_Leads" How do I go ...
0
votes
1answer
18 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 ...
2
votes
3answers
33 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
0answers
11 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 ...
1
vote
0answers
30 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
8 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
14 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
26 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
54 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
32 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
25 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
23 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
54 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
46 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
46 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
72 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
54 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
36 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 ...
0
votes
2answers
69 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
36 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
48 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
58 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
36 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
20 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
29 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
46 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
62 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
38 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
74 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
20 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
27 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
51 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
64 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
88 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
52 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
44 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
91 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
91 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
99 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
78 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
119 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 ...
1
vote
2answers
268 views

Bash substring last occurance of a character

I am trying to write a script that removes everything after the last occurrence of a character. For example if the string is DATETIME 2014.03.14 12:23:24, I would like to get just DATETIME 2014.03.. ...
0
votes
1answer
66 views

Extract stings between a delimiter if it matches a certain string

File cat hosts.cfg define host { host_name switchlan alias switchlan address ...
0
votes
1answer
63 views

How to find the matching records from 2 files in unix

I have two files which contains email_ids. 1. Test1.txt 2. Test2.txt Test1.txt contents are: abc@gmail.com xyz@gmail.com mns@gmail.com Test2.txt Contents are: jpg@gmail.com joy@yahoo.com ...
0
votes
1answer
138 views

sed exact match patterns of range and extract lines from thereon

I am trying to extract range from IP= to TUAL_HOSTNAME_=, as below. But its also extracting other match pattern for IP. sed -i -e '/IP=/,/TUAL_HOSTNAME_=/{w /tmp/101' -e 'd}' /tmp/install; #IP= ...
0
votes
1answer
57 views

Sort file with respect to a part of a column

I have one file that contains the details of space in data stores. I want to sort it according to the Free space available in them. File is : Name:VSP-01-32 Capacity:2047 Free Space:144 ...
1
vote
1answer
100 views

How to replace line in file with pattern with sed?

I'm reading a lot of documentation on sed, and am still stumped on my particular use case. I want to replace this line in a conf file with my own line: Replace this line: #maxmemory <bytes> ...
0
votes
1answer
231 views

How to replace text strings by reading in list using sed

I'm trying to come up with a sed script to run from the shell. I need to be able to read in a list of UUIDs from an external file, which contains two columns origtexta replacementa origtextb ...