01-16-2013
[SOLVED] - [ksh] finding last file with keyword in it
Quote:
Originally Posted by
RudiC
Not sure I understand your request.
So - the end time will be in the last file (key word END), and the begin (keyword BEGIN) will be in the same file or in four predecessors. Why not loop up to five times through ls -t LOG_hostx* (watch out, no -r option!), grepping each file for "BEGIN"? If there's more than one BEGIN and you need the last one, try tacing the files.
Indeed, this was the solution, I was on the wrong track.
That happens when you are expanding the code, or when you adapt the code to little changes.
In my case, first the BEGIN/END sequence was in the last file only, then spread over 2 files, then over 3 and currently over 4.
So I kept looking for the next file, not paying attention to a sound solution.
Now it can be in any file, so is future proof.
Thanks for responding.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi guys i have a problem here, im trying to stablish a relationship between a text file and an input user for example the script is going to prompt the user for some football team and what the script is going to do is return the colums in which that input is located so far this is what i have ... (6 Replies)
Discussion started by: lucho_1
6 Replies
2. Shell Programming and Scripting
I am trying to find for the pattern in first 5 bytes of every line in a text file and then generate a new file with the pattern found.
Example: expected pattern is '-' to be serached in first 5 bytes of file only.
Input File
ab-cd jan-09
ddddd jan09
cc-ww jan09
dsgdq jan-09
... (2 Replies)
Discussion started by: net
2 Replies
3. Shell Programming and Scripting
It saves me lot of typing and space/lines when I do not use full 'if' keyword and construct, instead use ..
&& <statement> || <statement>
that perfectly replaces..
if ; then
<statement>
else
<statement>
fi
Can I use following syntax when I want to add multiple statements under 'if'... (4 Replies)
Discussion started by: kchinnam
4 Replies
4. Solaris
Hi,
I have a file which got only one column and got some keywords. I have another file where the keywords used in the first file are repeated in the second file.
Now I would like to know how many times each keyword from the first file is repeated in the second file.
Request your help on... (1 Reply)
Discussion started by: pointers
1 Replies
5. Shell Programming and Scripting
Hi Guys,
I need to read a file until I find a blank line. and in the next iteration I want to continue reading from the line I find a keyword.
For ex: my file looks like
PDS_JOB_ALIAS
CRITERIA_ITEM_TYPE
PDS_JOB_CRITERIA_ITEM
CRITERIA_ITEM_TYPE
First I want to read the file... (2 Replies)
Discussion started by: infintenumbers
2 Replies
6. Shell Programming and Scripting
Hi,
I've to find the file which has the pattern
"Delete Report for History Tables"
and need to search this file pattern from directory which has sub directories as well.
I'm using ksh 88
Please suggest me which command will be used to find the file pattern .
Thanks. (1 Reply)
Discussion started by: smile689
1 Replies
7. Shell Programming and Scripting
Hi
I want to implement something like this:
if( keyword1 exists)
then
check if(keyword2 exists in the same line)
then replace keyword 2 with New_Keyword
else
Add New_Keyword at the end of line
end if
eg:
Check for Keyword JUNGLE and add/replace... (7 Replies)
Discussion started by: dashing201
7 Replies
8. Shell Programming and Scripting
Hi Everyone,
Need help in extracting the hostname from the below output.
Expected output:
DS-TESTB-GDS-1.TEST.ABC.COM
DS-TESTB-GDS-2.TEST.ABC.COM
....
...
/tmp $ cat -n /tmp/patchreport
1 /usr/bin/perl /admin/bin/patch/applyPatches.pl --apply_patches... (4 Replies)
Discussion started by: thiyagoo
4 Replies
9. Shell Programming and Scripting
I am trying to create an output file new that contains only the S5-00580 lines from list that are not in analysis_log. My attempt to do this is below.
The new file would be used in the aria2c command to download only new folders. The aria2c command works to download all the files in list, but... (7 Replies)
Discussion started by: cmccabe
7 Replies
10. UNIX for Beginners Questions & Answers
I have a csv file as shown below,
xop_thy 80 avr_njk 50 str_nyu 60
avr_irt 70 str_nhj 60 avr_ngt 50
str_tgt 80 xop_nmg 50 xop_nth 40
cyv_gty 40 cop_thl 40 vir_tyk 80
vir_plo 20 vir_thk 40 ijk_yuc 70
cop_thy 70 ijk_yuc 80 irt_hgt 80
I need to align/sort the csv file based... (7 Replies)
Discussion started by: dineshkumarsrk
7 Replies
BEGIN(7) SQL Commands BEGIN(7)
NAME
BEGIN - start a transaction block
SYNOPSIS
BEGIN [ WORK | TRANSACTION ]
INPUTS
WORK
TRANSACTION
Optional keywords. They have no effect.
OUTPUTS
BEGIN This signifies that a new transaction has been started.
WARNING: BEGIN: already a transaction in progress
This indicates that a transaction was already in progress. The current transaction is not affected.
DESCRIPTION
By default, PostgreSQL executes transactions in unchained mode (also known as ``autocommit'' in other database systems). In other words,
each user statement is executed in its own transaction and a commit is implicitly performed at the end of the statement (if execution was
successful, otherwise a rollback is done). BEGIN initiates a user transaction in chained mode, i.e., all user statements after BEGIN com-
mand will be executed in a single transaction until an explicit COMMIT [commit(7)] or ROLLBACK [rollback(7)]. Statements are executed more
quickly in chained mode, because transaction start/commit requires significant CPU and disk activity. Execution of multiple statements
inside a transaction is also useful to ensure consistency when changing several related tables: other clients will be unable to see the
intermediate states wherein not all the related updates have been done.
The default transaction isolation level in PostgreSQL is READ COMMITTED, wherein each query inside the transaction sees changes committed
before that query begins execution. So, you have to use SET TRANSACTION ISOLATION LEVEL SERIALIZABLE just after BEGIN if you need more rig-
orous transaction isolation. (Alternatively, you can change the default transaction isolation level; see the PostgreSQL Administrator's
Guide for details.) In SERIALIZABLE mode queries will see only changes committed before the entire transaction began (actually, before
execution of the first DML statement in the transaction).
Transactions have the standard ACID (atomic, consistent, isolatable, and durable) properties.
NOTES
START TRANSACTION [start_transaction(7)] has the same functionality as BEGIN.
Use COMMIT [commit(7)] or ROLLBACK [rollback(7)] to terminate a transaction.
Refer to LOCK [lock(7)] for further information about locking tables inside a transaction.
If you turn autocommit mode off, then BEGIN is not required: any SQL command automatically starts a transaction.
USAGE
To begin a user transaction:
BEGIN WORK;
COMPATIBILITY
SQL92
BEGIN is a PostgreSQL language extension. There is no explicit BEGIN command in SQL92; transaction initiation is always implicit and it
terminates either with a COMMIT or ROLLBACK statement.
Note: Many relational database systems offer an autocommit feature as a convenience.
Incidentally, the BEGIN keyword is used for a different purpose in embedded SQL. You are advised to be careful about the transaction seman-
tics when porting database applications.
SQL92 also requires SERIALIZABLE to be the default transaction isolation level.
SQL - Language Statements 2002-11-22 BEGIN(7)