Given a file , I need to delete , modify and insert lines matching certain patterns in that file using shell scripting.
e.g. If a file FILE1 has following content :
Then , I need to do following three modifications in the file FILE1:
1) I need to delete all lines with PRINTF statements.
2) I need to modify all instances of small "mid" word with capital "MID".
3) I need to insert a line containing "{" after line with IF statement.
I need to all above operations without reading file line by line to avoid performance issues because file may contain more than 10000 lines. And for the same reason, I want to avoid usage of temporary file.
Can anyone please suggest solution for stated problem ?
You have missed that you also require a "}" after an "ENDIF" So I have introduced it manually. seeing that you forgot it.
I am iterating record by record through a file as below,
A,B
A,C
A,D
B,E
B,F
E,G
E,H
The same file should look like in the final output as below,
A,B
B,E
E,G
E,H
B,F
A,C
A,D (10 Replies)
Hi Everyone,
Please help me with this. I have gone through many posts here but couldn't find what I wanted.
I have a file with 79000+ lines and I want to delete lines in a pattern.
I want to delete every 141st line in the file, starting from line 2000 till 50000.
Please help guys.
... (8 Replies)
I have below file say temp1
BSCAJM1:HWJA10C
BSCAJM1:
BSCALW1:
BSCALW1:GVND01B
BSCALW1:
BSCALW1:
BSCBKNR:IJNMKTA
BSCBKNR:
BSCJOD1:
BSCJOD1:JOD121B
i want to delete all the lines ending with : and have below output
BSCAJM1:HWJA10C
BSCALW1:GVND01B
BSCBKNR:IJNMKTA... (8 Replies)
Hi i need an help. I have two files list1 and list2, both contains the server names i want to delete the servers in list2 which were also found in list1.
for an eg
list2 list1
oradg1 oradg4
oradg2 oradg2
oradg3 ... (5 Replies)
I have a huge file with record length around 5000 characters.
There is an ETL tool datastage which is writing this data to the file(AIX server). At position 4095 i have seen NULL Character(^@).
when i am using this command "head -1 file_nm | sed 's/\000//g'" --- the output is displaying... (3 Replies)
I have 800+ html files that need to have a javascript added to them in the head. I can do the looping, setting filenames as variables, etc. but I cannot figure out how to insert my javascript file into the html.
My javascript is in a file named jsinsert.txt
It basically has this format:... (4 Replies)
so i have this data in a file:
jime=1860,yime=1.23243,lime=
jime=1859,yime=1.23018,lime=
jime=1825,yime=1.15371,lime=
jime=1849,yime=1.20769,lime=
jime=1841,yime=1.1897,lime=
jime=1849,yime=1.20769,lime=
i use this code to calculate the percentage difference of the number in column 2... (9 Replies)
Hi,
I am in stage of post processing some of my results. I wanted to plot the data against the three axis x,y,z. The data file is quite complicated and i have to take the average of x, y,z over different steps of my test. A typical file look like below:
Time taken:4s
No.of series : 3... (6 Replies)
Hi, I'm currently dev'ing using awk and I'm currently stuck.
Here's the file, with comments on "<--- ":
Record <--- First Pattern
Amount 1 <--- Amount on first transaction
TotalSales 0 <--- Total Sales Prior from previous transactions
Time 1:00:00 <--- Time... (9 Replies)
Discussion started by: Jin_
9 Replies
LEARN ABOUT DEBIAN
rrdxport
RRDXPORT(1) rrdtool RRDXPORT(1)NAME
rrdxport - Export data in XML format based on data from one or several RRD
SYNOPSIS
rrdtool xport [-s|--start seconds] [-e|--end seconds] [-m|--maxrows rows] [--step value] [--json] [--daemon address] [DEF:vname=rrd:ds-
name:CF] [CDEF:vname=rpn-expression] [XPORT:vname[:legend]]
DESCRIPTION
The xport function's main purpose is to write an XML formatted representation of the data stored in one or several RRDs. It can also
extract numerical reports.
If no XPORT statements are found, there will be no output.
-s|--start seconds (default end-1day)
The time when the exported range should begin. Time in seconds since epoch (1970-01-01) is required. Negative numbers are relative to
the current time. By default one day worth of data will be printed. See also AT-STYLE TIME SPECIFICATION section in the rrdfetch
documentation for a detailed explanation on how to specify time.
-e|--end seconds (default now)
The time when the exported range should end. Time in seconds since epoch. See also AT-STYLE TIME SPECIFICATION section in the rrdfetch
documentation for a detailed explanation of ways to specify time.
-m|--maxrows rows (default 400 rows)
This works like the -w|--width parameter of rrdgraph. In fact it is exactly the same, but the parameter was renamed to describe its
purpose in this module. See rrdgraph documentation for details.
--step value (default automatic)
See rrdgraph documentation.
--daemon address
Address of the rrdcached daemon. If specified, a "flush" command is sent to the server before reading the RRD files. This allows
rrdtool to return fresh data even if the daemon is configured to cache values for a long time. For a list of accepted formats, see the
-l option in the rrdcached manual.
rrdtool xport --daemon unix:/var/run/rrdcached.sock ...
--json
produce json formated output (instead of xml)
--enumds
The generated xml should contain the data values in enumerated tags.
<v0>val</v0><v1>val</v1>
DEF:vname=rrd:ds-name:CF
See rrdgraph documentation.
CDEF:vname=rpn-expression
See rrdgraph documentation.
XPORT:vname::legend
At least one XPORT statement should be present. The values referenced by vname are printed. Optionally add a legend.
Output format
The output is enclosed in an xport element and contains two blocks. The first block is enclosed by a meta element and contains some meta
data. The second block is enclosed by a data element and contains the data rows.
Let's assume that the xport command looks like this:
rrdtool xport
--start now-1h --end now
DEF:xx=host-inout.lo.rrd:output:AVERAGE
DEF:yy=host-inout.lo.rrd:input:AVERAGE
CDEF:aa=xx,yy,+,8,*
XPORT:xx:"out bytes"
XPORT:aa:"in and out bits"
The resulting meta data section is (the values will depend on the RRD characteristics):
<meta>
<start>1020611700</start>
<step>300</step>
<end>1020615600</end>
<rows>14</rows>
<columns>2</columns>
<legend>
<entry>out bytes</entry>
<entry>in and out bits</entry>
</legend>
</meta>
The resulting data section is:
<data>
<row><t>1020611700</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020612000</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020612300</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020612600</t><v>3.4113333333e+00</v><v>5.4581333333e+01</v></row>
<row><t>1020612900</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020613200</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020613500</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020613800</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020614100</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020614400</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020614700</t><v>3.7333333333e+00</v><v>5.9733333333e+01</v></row>
<row><t>1020615000</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020615300</t><v>3.4000000000e+00</v><v>5.4400000000e+01</v></row>
<row><t>1020615600</t><v>NaN</v><v>NaN</v></row>
</data>
EXAMPLE 1
rrdtool xport
DEF:out=if1-inouts.rrd:outoctets:AVERAGE
XPORT:out:"out bytes"
EXAMPLE 2
rrdtool xport
DEF:out1=if1-inouts.rrd:outoctets:AVERAGE
DEF:out2=if2-inouts.rrd:outoctets:AVERAGE
CDEF:sum=out1,out2,+
XPORT:out1:"if1 out bytes"
XPORT:out2:"if2 out bytes"
XPORT:sum:"output sum"
ENVIRONMENT VARIABLES
The following environment variables may be used to change the behavior of "rrdtool xport":
RRDCACHED_ADDRESS
If this environment variable is set it will have the same effect as specifying the "--daemon" option on the command line. If both are
present, the command line argument takes precedence.
AUTHOR
Tobias Oetiker <tobi@oetiker.ch>
1.4.7 2012-01-16 RRDXPORT(1)