Sed is a command-line stream editor for filtering and transforming text.

learn more… | top users | synonyms

2
votes
6answers
85 views

Printing specific section of a line when a trigger value is present

I'm parsing data in the following format: prop1=value1:prop2=value2:prop3=value3+prop1=value4:prop2=value5 parts of the string are delimited by + properties can appear in any order the desired ...
0
votes
4answers
46 views

Adding a character to every other text line

I have a huge (ca. 20G) text file which contains millions of passages (a.k.a. paragraphs) with headers. Headers and paragraphs are always one line each, e.g., Sunshine This is a sunny day. ...
2
votes
3answers
98 views

Reverse match in sed, replace opposite of what was found

Say I have this output from my syslog, precalculated src_hash => 20 bytes @ 0x7f811c001e20 A6 2D E5 CD 2A BA F0 42 56 66 19 D4 61 1A E3 A0 .-..*..BVf..a... C7 5E 5F 77 ...
0
votes
3answers
37 views

Finding and replacing text inside awk block

I want to find and replace a value inside awk block. Here is a sample input file to my script P1 10,9:11/18013013582 ,10:1 ,167:0 ,487:5/E.164 11,9:15/310410532169026 ,10:60 ,167:0 ,487:4/IMSI ...
0
votes
3answers
210 views

For all files that does not contain a string, prepend a string to the file

I am trying to iterate through a list of html files, check to see if {% load static from staticfiles %} exists in the file and if it does not exists, prepend {% load static from staticfiles %} to it. ...
3
votes
2answers
547 views

Split log file by time range

I have a log file and would like to cut it into copies of 15min. In the log file the lines start with: dd mmm yyyy hh:mm:ss,xxx e.g. 12 Feb 2013 16:05:02,xxx log text... and the file rotates ...
1
vote
2answers
102 views

Compare set of values from two files and print the output in third file in awk

Hi friends i have problem with comparing two files.I'll try my best to explain.I have two file f1 and f2 which i have to compare on basis of two sets Parameter(p) and Value(v). Basically f1 contains ...
1
vote
1answer
113 views

Insert a line after a block of text with sed

I have text file: file.conf ### Option: LogFile # Name of log file. # If not set, syslog is used. # # Mandatory: no # Default: # LogFile= ### Option: LogFileSize # Maximum size of ...
0
votes
1answer
42 views

Remove given parts of a string with sed?

$ echo '<a href="mailto:NA?Subject=AB42525216 - FOOBAR bla bla - bla">NA</a>' <a href="mailto:NA?Subject=AB42525216 - FOOBAR bla bla - bla">NA</a> $ echo '<a ...
0
votes
1answer
30 views

sed replace misplaces slashes

I have the following code in a LaTeX file: for \emph{service} in \emph{host}.resources: for \emph{file} in \emph{host}.resources: \underline{service}.requires.add(\underline{file}) ...
0
votes
1answer
126 views

Search for pattern across multiple files and replace a sub-part in all occurences

I am helping a friend with her thesis written in LaTeX and I need a quick solution for a "search and replace". Using a terminal in Linux, how can I find the following pattern: \caption{*\cite{*}} ...
0
votes
1answer
208 views

How do I use the SED command to remove injected code from multiple files?

One of the domains on my Centos 6.5 (64 bit) server has been compromised. Having run a detection script on the public_html folder I have identified all the files with this code injection. I ...
-1
votes
1answer
23 views

How do I change the Old Directory path to New Directory path using SED command

I have the old path it contains the some files. /home/ubuntu/Desktop/test-dir Now I want to change the test-dir to new-test-dir directory. /home/ubuntu/Desktop/new-test-dir How do I change ...
7
votes
0answers
89 views

regarding portable sed -e… d b or ! b?

In this edit Stéphane Chazelas POSIXifies (again) my sed formatting by inserting an -expression break and another -expression statement. Now, I might just ask him why in the comments, I suppose, but ...
2
votes
0answers
1k views

sed couldn't flush stdout no space left on device?

What could be the reason for this error : sed couldn't flush stdout no space left on device This is come of the stuff that i am doing at last in my code sed -n '/.*needs to be executed ...
1
vote
0answers
18 views

Create files from templates, substitutions in middle of other words

Is there a way to convince m4 to replace a macro in the middle of a word? I would like this file, day.m4: define(Sat,Cat)dnl Saturday and this command: m4 day.m4 to produce this output: ...
1
vote
0answers
519 views

Dynamic search and replace in Ksh

Machines at work follow a constant naming pattern: host[domain]_[id] where [domain] is either "d" for dev machines and "p" for production machines, and [id] is a 2-digit string that is different for ...
0
votes
0answers
52 views

Can sed and awk take in multiple files?

grep can search in multiple files, including those files recursively under a specified directory. This makes grep able to find which file contains a pattern. Can awk and sed also? It seems that they ...
-3
votes
0answers
25 views

How to extract strings from a given input file and store them in two different files in a column wise manner

Given below is the input file pattern: *********************************************************** Search URL: ...