07-10-2008
Need solution concatenate and display 2 lines as 1 with a condition for 2 line ?
I have 2 pattern of lines (SQL query and Time taken)in a log i need to capture all SQL queries with time taken >20 sec and need to display as one line.
2 lines from log:
2007-10-23 11:39:17,061 DEBUG [server.startup : 1] [com.fourcs.clm.fw.pem.CLMPEMDBService] - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN C WHERE A.GROUP_ID = B.GROUP_ID AND B.FN_ID = C.FN_ID ORDER BY A.GROUP_CD
2007-10-23 11:39:17,061 DEBUG [server.startup : 1] [com.fourcs.clm.fw.pem.CLMPEMDBService] - Time Taken : 640
i have tried to display results Time taken > 20000 by using a command but i want this results to be concatenated with above line(SQL Query line) for Time taken > 20000
Commands:
cd /logs/WS/apps/logs
grep -i 'Time Taken :' /logs/WS/apps/logs/SQLPerformance_x1prdapp7*Node01_C*S*.log > /export/home/jftl784/script/Latest_SQLTIME_TMP.txt
awk '$12 > 20000 {print $0}' < /export/home/jftl784/script/Latest_SQLTIME_TMP.txt > /export/home/jftl784/script/Latest_SQLTIME_TMP_2.txt
grep -v 'Non-deferrable Alarm :' < /export/home/jftl784/script/Latest_SQLTIME_TMP_2.txt > /export/home/jftl784/script/Latest_SQLTIME_MSGS_$1.txt
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I would like to know , how to concatenate two command in one line and get the display in one screen
for eg
command 1 : ls -l /data/logs
command 2 : ls -l /data/errors
output shd be
/data/logs /data/errors
xx-xx-xx-xx abc.log xx-xx-xx-xx... (9 Replies)
Discussion started by: vasikaran
9 Replies
2. UNIX for Dummies Questions & Answers
I have a file that has 1k lines and i want to print all the lines after 900th line.
an 2)I want to move files f1 ,f2,f3,f4 to p1,p2,p3,p4
Please give me the commands.
Thanx in adv. (6 Replies)
Discussion started by: rajashekar.y
6 Replies
3. Shell Programming and Scripting
I have 2 pattern of lines (SQL query and Time taken)in a log i need to capture all SQL queries with time taken >20 sec and need to display as one line.
2 lines from log:
2007-10-23 11:39:17,061 DEBUG - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN... (7 Replies)
Discussion started by: vithala
7 Replies
4. Shell Programming and Scripting
write a shell script that accepts a file name starting and ending line numbers as arguments and displays all the lines between the given line numbers:b:.help is appreciated.thank you. (3 Replies)
Discussion started by: shawz
3 Replies
5. UNIX for Advanced & Expert Users
Hi
I am getting a source file where the columns are seperated by comma and double Quotes
Eg1 : "AAA","BBB","CCCC"
in the same source file i am also getting few lines where my last columns double quotes are ending in its next line or the next next line
Eg2: "AAA","BBB","CCC
CC"... (9 Replies)
Discussion started by: laxmi131
9 Replies
6. Shell Programming and Scripting
I've got a log file from automatic diagnostic runs. The log file is appended to each time an automatic log is run.
I'd like to just pull certain lines from each run in the log file, and concatenate them into 1 comma delimited line (for export into excel or an html table).
Each diagnostic run... (3 Replies)
Discussion started by: BecTech
3 Replies
7. Shell Programming and Scripting
Sample input (line feed indicated by )
---------------
The red fox jumped
over the brown fence of the
red hous
He then went into the
orchard
---------------
Desired Output
---------------
The red fox jumped over the brown fence of the red house
He then went into the orchard (11 Replies)
Discussion started by: dunstonrocks
11 Replies
8. Shell Programming and Scripting
hello everyone
my file contains many records, the following is a sample:
BEGIN
ASX1500000050002010120000000308450201012000177
ASX1100002000000201012000000038450201012000220
ASX1600100005000201012000000038450020101200177
ASX1900100006000201067000000058450020101200177... (2 Replies)
Discussion started by: neemoze
2 Replies
9. Shell Programming and Scripting
Here is an example of a file...
foo1,good
foo1,good
foo2,error
foo2,good
Note that both rows for foo1 have good in the 2nd field, but one of the foo2 rows has error...
I need something in ksh/awk/perl that will delete ALL foo2 lines if ANY of them have error in the 2nd field...so:
... (7 Replies)
Discussion started by: dbiggied
7 Replies
10. Shell Programming and Scripting
Hi,
I have a file like below.
1,2,3,4,5,6,7,8,9I would like to print or copied to a file based of line count in perl
If I gave a condition 1 to 3 then it should iterate over above file and print 1 to 3 and then again 1 to 3 etc.
output should be
1,2,3
4,5,6
7,8,9 (10 Replies)
Discussion started by: Anjan1
10 Replies
LEARN ABOUT DEBIAN
stag-selectall_xml
SELECTALL_XML(1p) User Contributed Perl Documentation SELECTALL_XML(1p)
NAME
stag-selectall_xml - Query all elements from database with an XML output
SYNOPSIS
stag-selectall_xml [-d <dbi>] [-f file of sql] [-nesting|n <nesting>] SQL
DESCRIPTION
This script will query a database using either SQL provided by the script user, or using an SQL templates; the query results will be turned
into XML using the DBIx::DBStag module. The nesting of the XML can be controlled by the DBStag SQL extension "USE NESTING..."
EXAMPLES
stag-selectall_xml -d "dbi:Pg:dbname=mydb;host=localhost"
"SELECT * FROM a NATURAL JOIN b"
TEMPLATES
A parameterized SQL template (canned query) can be used instead of specifying the full SQL
For example:
stag-selectall_xml -d genedb /genedb-gene gene_symbol=Adh
Or:
stag-selectall_xml -d genedb /genedb-gene Adh
Or:
stag-selectall_xml -d genedb /genedb-gene gene_symbol@=Adh,dpp,bam,indy
A template is indicated by the syntactic shorthand of using a slash to precede the template name; in this case the template is called
genedb-gene. the -t option can also be used.
All the remaining arguments are passed in as SQL template parameters. They can be passed in as either name=value pairs, or as a simple list
of arguments which get passed into the template in order
To use templates, you should have the environment variable DBSTAG_TEMPLATE_DIRS set. See DBIx::DBStag for details.
LISTING AVAILABLE TEMPLATES FOR A DB
stag-selectall_xml -d mydb -h
LISTING VARIABLES FOR A TEMPLATE
stag-selectall_xml /genedb-gene -h
ENVIRONMENT VARIABLES
DBSTAG_DBIMAP_FILE
A file containing configuration details for local databases
DBSTAG_TEMPLATE_DIRS
list of directories (separated by :s) to be searched when templates are requested
COMMAND LINE ARGUMENTS
-h|help
shows this page if no other arguments are given
if a template is specified, gives template details
if a db is specified, lists templates for that db
use in conjunction with -v for full descriptions
-d|dbname DBNAME
this is either a full DBI locator string (eg dbi:Pg:dbname=mydb;host=localhost) or it can also be a shortened "nickname", which is then
looked up in the file pointed at by the environment variable DBSTAG_DBIMAP_FILE
-u|user USER
database user identity
-p|password PASS
database password
-f|file SQLFILE
this is a path to a file containing SQL that will be executed, as an alternative to writing the SQL on the command line
-n|nesting NESTING-EXPRESSIONS
a bracketed expression indicating how to the resulting objects/XML should be nested. See DBIx::DBStag for details.
-t|template TEMPLATE-NAME
the name of a template; see above
-wh|where WHERE-CLAUSE
used to override the WHERE clause of the query; useful for combining with templates
You can append to an existing where clause by using the prefix +
-s|select SELECT-COLS
used to override the SELECT clause of the query; useful for combining with templates
-rows
sometimes it is preferable to return the results as a table rather than xml or a similar nested structure. specifying -rows will fetch
a table, one line per row, and columns separated by tabs
-pre SQL
a piece of SQL is that is executed immediately before the main query; e.g.:
-pre "SET search_path=myschema,public"
-o|out FILE
a file to output the results to
-w|writer WRITER
writer class; can be any perl class, or one of these
xml [default]
sxpr
lisp S-Expressions
itext
indented text
-color
shows results in color (sxpr and itext only)
-show
will show the parse of the SQL statement
perl v5.12.4 2011-10-14 SELECTALL_XML(1p)