Sponsored Content
Top Forums Shell Programming and Scripting Compare date from db2 table to yesterday's Unix system date Post 302188412 by sasaliasim on Wednesday 23rd of April 2008 11:59:02 AM
Old 04-23-2008
Compare date from db2 table to yesterday's Unix system date

I am currently running the following Korn shell script which works fine:

#!/usr/bin/ksh
count=`db2 -x "select count(*) from schema.tablename"`
echo "count"

I would like to add a "where" clause to the 2nd line that would allow me to get a record count of all the records from schema.tablename where PROCESS_DT(a datetime variable in tablename which is formatted as DATE9.) is equal to the today's unix system date - 1. I'm not sure of the proper syntax. Please help.

count=`db2 -x "select count(*) from schema.tablename where PROCESS_DT=UNIX system date-1"`
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to get what date was 28 days ago of the current system date IN UNIX

Hi, Anybody knows how to get what date was 28 days ago of the current system date through UNIX script. Ex : - If today is 28th Mar 2010 then I have to delete the files which arrived on 1st Mar 2010, (15 Replies)
Discussion started by: kandi.reddy
15 Replies

2. Shell Programming and Scripting

Need help in Shell Script comparing todays date with Yesterday date from Sysdate

Hi, I want to compare today's date(DDMMYYYY) with yesterday(DDMMYYYY) from system date,if (today month = yesterday month) then execute alter query else do nothing. The above requirement i want in Shell script(KSH)... Can any one please help me? Double post, continued here. (0 Replies)
Discussion started by: kumarmsk1331
0 Replies

3. Shell Programming and Scripting

Adding days to system date then compare to a date

Hi! I am trying to read a file and every line has a specific date as one of its fields. I want to take that date and compare it to the date today plus 6 days. while read line do date=substr($line, $datepos, 8) #date is expected to be YYYYMMDD if ; then ...proceed commands ... (1 Reply)
Discussion started by: kokoro
1 Replies

4. Shell Programming and Scripting

[Solved] Replace yesterday date with today's date except from the first line

Hello, I have a file like this: 2012112920121130 12345620121130msABowwiqiq 34477420121129amABamauee e7748420121130ehABeheheei in case the content of the file has the date of yesterday within the lines containing pattern AB this should be replaced by the current date. But if I use... (3 Replies)
Discussion started by: Lilu_CK
3 Replies

5. Shell Programming and Scripting

How to get tomorrow,yesterday date from date Command

Hi I want to get tomorrow and yesterday date from date command. My shell is KSH and server is AIX. I tried several options, but unable to do. Please help on this. Regards Rajesh (5 Replies)
Discussion started by: rajeshmepco
5 Replies

6. Shell Programming and Scripting

How to append date to filename, but base it on yesterday's date?

Hello, I'd like to write a monthly archive script that archives some logs. But I'd like to do it based on yesterday's date. In other words, I'd like to schedule the script to run on the 1st day of each month, but have the archive filename include the previous month instead. Here's what I... (5 Replies)
Discussion started by: nbsparks
5 Replies

7. Shell Programming and Scripting

Shell script to compare two files of todays date and yesterday's date

hi all, How to compare two files whether they are same are not...? like i had my input files as 20141201_file.txt and 20141130_file2.txt how to compare the above files based on date .. like todays file and yesterdays file...? (4 Replies)
Discussion started by: hemanthsaikumar
4 Replies

8. Shell Programming and Scripting

Compare the system date with date from a text file

I get the date that's inside a text file and assigned it to a variable. When I grep the date from the file, I get this, Not After : Jul 28 14:09:57 2017 GMT So I only crop out the date, with this command echo $dateFile | cut -d ':' -f 2,4The result would be Jul 28 14:57 2017 GMT How do I... (3 Replies)
Discussion started by: Loc
3 Replies

9. UNIX for Beginners Questions & Answers

Compare date in .txt with system date and remove if it's lesser than system date

Can someone help me with the code wherein there is a file f1.txt with different column and 34 column have expiry date and I need to get that and compare with system date and if expiry date is <system date remove those rows and other rows should be moved to new file f2.txt . I don't want to delete... (2 Replies)
Discussion started by: Stuti
2 Replies

10. Answers to Frequently Asked Questions

Compare date in .txt with system date and remove if it's lesser than system date

I m working on shell scripting and I m stuck where in my .txt file there is column as expiry date and I need to compare that date with system date and need to remove all the rows where expiry date is less than system date and create a new .txt with update. (1 Reply)
Discussion started by: Stuti
1 Replies
nismatch(1)							   User Commands						       nismatch(1)

NAME
nismatch, nisgrep - utilities for searching NIS+ tables SYNOPSIS
nismatch [-AchMoPv] [-s sep] key tablename nismatch [-AchMoPv] [-s sep] colname = key... tablename nismatch [-AchMoPv] [-s sep] indexedname nisgrep [-AchiMov] [-s sep] keypat tablename nisgrep [-AchiMov] [-s sep] colname = keypat... tablename DESCRIPTION
The utilities nismatch and nisgrep can be used to search NIS+ tables. The command nisgrep differs from the nismatch command in its ability to accept regular expressions keypat for the search criteria rather than simple text matches. Because nisgrep uses a callback function, it is not constrained to searching only those columns that are specifically made searchable at the time of table creation. This makes it more flexible, but slower, than nismatch. In nismatch, the server does the searching, whereas in nisgrep the server returns all the readable entries and then the client does the pattern-matching. In both commands, the parameter tablename is the NIS+ name of the table to be searched. If only one key or key pattern is specified with- out the column name, then it is applied searching the first column. Specific named columns can be searched by using the colname=key syntax. When multiple columns are searched, only entries that match in all columns are returned. This is the equivalent of a logical join opera- tion. nismatch accepts an additional form of search criteria, indexedname, which is a NIS+ indexed name of the form: [ colname=value, ... ],tablename OPTIONS
The following options are supported: -A All data. Return the data within the table and all of the data in tables in the initial table's concatenation path. -c Print only a count of the number of entries that matched the search criteria. -h Display a header line before the matching entries that contains the names of the table's columns -i Ignore upper/lower case distinction during comparisons. -M Master server only. Send the lookup to the master server of the named data. This guarantees that the most up to date infor- mation is seen at the possible expense that the master server may be busy. -o Display the internal representation of the matching NIS+ object(s). -P Follow concatenation path. Specify that the lookup should follow the concatenation path of a table if the initial search is unsuccessful. -s sep This option specifies the character to use to separate the table columns. If no character is specified, the default separa- tor for the table is used. -v Verbose. Do not suppress the output of binary data when displaying matching entries. Without this option binary data is displayed as the string *BINARY*. EXAMPLES
Example 1: Searching a table for a username This example searches a table named passwd in the org_dir subdirectory of the zotz.com. domain. It returns the entry that has the user- name of skippy. In this example, all the work is done on the server: example% nismatch name=skippy passwd.org_dir.zotz.com. Example 2: Finding users using specific shells This example is similar to the one above, except that it uses nisgrep to find all users in the table named passwd that are using either ksh(1) or csh(1): example% nisgrep 'shell=[ck]sh' passwd.org_dir.zotz.com. ENVIRONMENT VARIABLES
NIS_PATH If this variable is set, and the NIS+ table name is not fully qualified, each directory specified will be searched until the table is found (see nisdefaults(1)). EXIT STATUS
The following exit values are returned: 0 Successfully matches some entries. 1 Successfully searches the table and no matches are found. 2 An error condition occurs. An error message is also printed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWnisu | +-----------------------------+-----------------------------+ SEE ALSO
niscat(1), nisdefaults(1), nisls(1), nistbladm(1), nis_objects(3NSL), attributes(5) DIAGNOSTICS
No memory An attempt to allocate some memory for the search failed. tablename is not a table The object with the name tablename was not a table object. Can't compile regular expression The regular expression in keypat was malformed. column not found: colname The column named colname does not exist in the table named tablename. NOTES
NIS+ might not be supported in future releases of the SolarisTM Operating Environment. Tools to aid the migration from NIS+ to LDAP are available in the Solaris 9 operating environment. For more information, visit http://www.sun.com/directory/nisplus/transition.html. SunOS 5.10 10 Dec 2001 nismatch(1)
All times are GMT -4. The time now is 10:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy