Sponsored Content
Full Discussion: dynamic output
Top Forums Shell Programming and Scripting dynamic output Post 302410525 by durden_tyler on Tuesday 6th of April 2010 08:14:33 AM
Old 04-06-2010
Quote:
Originally Posted by nitinrp1
...
Assume if there are space before xxx_yyy_aaa_01 , can pls provide me the perl script for this.

SEL elapsedtime ,StartTime,QueryText
FROM dbc.qry
WHERE StartTime >= '2010-03-24 20:10:08'
AND username = 'xxx_yyy_aaa_01'
ORDER BY LastRespTime DESC

or

SEL elapsedtime ,StartTime,QueryText
FROM dbc.qry
WHERE StartTime >= '2010-03-24 20:10:08'
AND username in 'xxx_yyy_aaa_01'
ORDER BY LastRespTime DESC
Here are a few cases I could think of -

Code:
$
$
$ # equal-to (=) operator not followed by space
$ cat file1.sql
SEL elapsedtime ,StartTime,QueryText
FROM     dbc.qry
WHERE    StartTime >= '2010-03-24 20:10:08'
        AND      username ='xxx_yyy_aaa_01'
ORDER    BY LastRespTime DESC
$
$ perl -lne '/^(\s*\w+){2}\s*(.*?)[\s(]*.xxx_yyy_aaa_01.*$/ && print $2' file1.sql
=
$
$ # equal-to (=) operator followed by a space
$ cat file2.sql
SEL elapsedtime ,StartTime,QueryText
FROM     dbc.qry
WHERE    StartTime >= '2010-03-24 20:10:08'
        AND      username = 'xxx_yyy_aaa_01'
ORDER    BY LastRespTime DESC
$
$ perl -lne '/^(\s*\w+){2}\s*(.*?)[\s(]*.xxx_yyy_aaa_01.*$/ && print $2' file2.sql
=
$
$ # IN operator followed by bracket "(" not followed by space
$ cat file3.sql
SEL elapsedtime ,StartTime,QueryText
FROM     dbc.qry
WHERE    StartTime >= '2010-03-24 20:10:08'
        AND      username in('xxx_yyy_aaa_01')
ORDER    BY LastRespTime DESC
$
$ perl -lne '/^(\s*\w+){2}\s*(.*?)[\s(]*.xxx_yyy_aaa_01.*$/ && print $2' file3.sql
in
$
$ # IN operator followed by space followed by bracket "("
$ cat file4.sql
SEL elapsedtime ,StartTime,QueryText
FROM     dbc.qry
WHERE    StartTime >= '2010-03-24 20:10:08'
        AND      username in ('xxx_yyy_aaa_01')
ORDER    BY LastRespTime DESC
$
$ perl -lne '/^(\s*\w+){2}\s*(.*?)[\s(]*.xxx_yyy_aaa_01.*$/ && print $2' file4.sql
in
$
$ # IN operator followed by space not followed by bracket "("
$ cat file5.sql
SEL elapsedtime ,StartTime,QueryText
FROM     dbc.qry
WHERE    StartTime >= '2010-03-24 20:10:08'
        AND      username in 'xxx_yyy_aaa_01'
ORDER    BY LastRespTime DESC
$
$ perl -lne '/^(\s*\w+){2}\s*(.*?)[\s(]*.xxx_yyy_aaa_01.*$/ && print $2' file5.sql
in
$
$

HTH,
tyler_durden
 

10 More Discussions You Might Find Interesting

1. OS X (Apple)

Dynamic DNS

I have a need to regularly add all macs in our domain to dns. Ideally it would work like Wintel machines. Transparently and automatically. What are the tools, scripts, roadblocks to doing so? I'm not talking about DynDNS type of service here. This is the internal dns for where I work. (0 Replies)
Discussion started by: [MA]Flying_Meat
0 Replies

2. Linux

how to dynamic DNS

hi i am using fedora core 5 and i already configured the dhcp server and the dns server but i want to configure dynamic dns to update the dns automatiklly thank you in advance (1 Reply)
Discussion started by: bondoq
1 Replies

3. Programming

dynamic linking

Hi, Could any one tell me solution for this. i have a library in my /usr/lib and latest in /myhome/lib/ (thay differ functionality symbols my application uses symbols from latest lib). when compile and link my application , every thing goes fine but when running the application ld... (4 Replies)
Discussion started by: Raom
4 Replies

4. UNIX for Advanced & Expert Users

Sql dynamic table / dynamic inserts

I have a file that reads File (X.txt) Contents of record 1: rdrDESTINATION_ADDRESS (String) "91 971502573813" rdrDESTINATION_IMSI (String) "000000000000000" rdrORIGINATING_ADDRESS (String) "d0 movies" rdrORIGINATING_IMSI (String) "000000000000000" rdrTRAFFIC_EVENT_TIME... (0 Replies)
Discussion started by: magedfawzy
0 Replies

5. Shell Programming and Scripting

Parsing dynamic data from a command output

Hi people, I am writing a korn shell script, and one of the command gives an output something like below: release.label.2010.03.02 objects: /project/path/to/some/file_name.ksh /project/path/another/file_name01.dat I have to retrieve the file paths one by one & use them as... (9 Replies)
Discussion started by: kiwin1000
9 Replies

6. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

7. Red Hat

Dynamic case creation based on output list from a command

I am attempting to create a script that would allow me to list all the instances associated with a DB2 and then prompt the user to choose which one to issue the db2profile command against. I use the db2 command db2ilist to get a list of the instances for a particular server, but the number of... (1 Reply)
Discussion started by: slatoms
1 Replies

8. Shell Programming and Scripting

Dynamic case creation based on output list from a command

I am attempting to create a script that would allow me to list all the instances associated with a DB2 and then prompt the user to choose which one to issue the db2profile command against. I use the db2 command db2ilist to get a list of the instances for a particular server, but the number of... (7 Replies)
Discussion started by: slatoms
7 Replies

9. Shell Programming and Scripting

Assign output to dynamic variable

Hi Folks, I am trying to assign a value from the command to a dynamic variable. But I am not getting the desired output.. I am sure something is wrong so i need experts advise. There will be multiple files like /var/tmp/server_1, /var/tmp/server_2, /var/tmp/server_3, having different server... (6 Replies)
Discussion started by: ganga.dharan
6 Replies

10. UNIX for Dummies Questions & Answers

awk : dynamic output flatfile filename

Hello, I'm using the awk command to insert empty columns on a tab delimited flatfile - which works fine - => But I'm not able to manage dynamicaly the filename of the awk output based on the source flatfile filename I have 3 source flatfile: flatfile_Jan-2016.csv flatfile_Feb-2016.csv... (3 Replies)
Discussion started by: Tipiak
3 Replies
ATF-SH(1)						    BSD General Commands Manual 						 ATF-SH(1)

NAME
atf-sh [-s shell] -- interpreter for shell-based test programs SYNOPSIS
atf-sh script DESCRIPTION
atf-sh is an interpreter that runs the test program given in script after loading the atf-sh(3) library. atf-sh is not a real interpreter though: it is just a wrapper around the system-wide shell defined by ATF_SHELL. atf-sh executes the inter- preter, loads the atf-sh(3) library and then runs the script. You must consider atf-sh to be a POSIX shell by default and thus should not use any non-standard extensions. The following options are available: -s shell Specifies the shell to use instead of the value provided by ATF_SHELL. ENVIRONMENT
ATF_LIBEXECDIR Overrides the builtin directory where atf-sh is located. Should not be overridden other than for testing purposes. ATF_PKGDATADIR Overrides the builtin directory where libatf-sh.subr is located. Should not be overridden other than for testing purposes. ATF_SHELL Path to the system shell to be used in the generated scripts. Scripts must not rely on this variable being set to select a specific interpreter. EXAMPLES
Scripts using atf-sh(3) should start with: #! /usr/bin/env atf-sh Alternatively, if you want to explicitly choose a shell interpreter, you cannot rely on env(1) to find atf-sh. Instead, you have to hardcode the path to atf-sh in the script and then use the -s option afterwards as a single parameter: #! /path/to/bin/atf-sh -s/bin/bash ENVIRONMENT
ATF_SHELL Path to the system shell to be used in the generated scripts. SEE ALSO
atf-sh(3) BSD
September 27, 2014 BSD
All times are GMT -4. The time now is 02:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy