Sponsored Content
Top Forums Shell Programming and Scripting Date Calculations using script!! Post 302558527 by anishkumarv on Saturday 24th of September 2011 01:58:09 PM
Old 09-24-2011
Hi,

This is the Exact fiile

Quote:
select b.id as cli_id,b.login as cli_login, b.pname as cli_name, b.cname as cli_company, b.phone as cli_phone, b.email as cli_email, (select (value / 1048576) from Limits where limit_name='disk_space' and id=b.limits_id) as Client_Package, b.cr_date, (select FROM_UNIXTIME(value,"%Y-%m-%d") from Limits where limit_name='expiration' and id=b.limits_id) as Client_expire, If(b.status=0,'Active','Inactive') as Cli_Status, a.name as dom_name, If(a.status=0,'Active','Inactive') as Dom_Package, a.cr_date as dom_create, (select FROM_UNIXTIME(value,"%Y-%m-%d") from Limits where limit_name='expiration' and id=a.limits_id) as dom_expire, (select (value / 1048576) from Limits where limit_name='disk_space' and id=a.limits_id) as Dom_Package, round((a.real_size / 1048576)) as Dom_usage from domains a, clients b where (select FROM_UNIXTIME(value,"%Y-%m-%d") from Limits where limit_name='expiration' and id=a.limits_id and (FROM_UNIXTIME(value,"%Y-%m-%d") between '2011-08-01' and '2011-12-01') ) and a.cl_id=b.id group by a.id;

'2011-08-01' and '2011-12-01'

i need to change this date part alone change every time.

between 'current month -1month' and 'current month + 3 months'

any help using AWK appriciated

---------- Post updated at 11:05 PM ---------- Previous update was at 06:16 AM ----------

Hi all,

I used this commad but still no luck :-(


Code:
sed -i "/between  '2011-08-01' and '2011-12-01'/'between '$(date --date="- 1 month" +%Y-%m)-01' and '$(date --date="+ 3 months" +%Y-%m)-01'/g" /var/tmp/p.sql

With Regard
Anish kumar.V

---------- Post updated at 11:28 PM ---------- Previous update was at 11:05 PM ----------

Code:
sed "s/between[^)]*/between '$(date --date="- 1 month" +%Y-%m)-01' and '$(date --date="+ 3 months" +%Y-%m)-01'/" /var/tmp/p.sql

using this i got the output what i expect :-)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

any way to speed up calculations in bash script

hi i have a script that is taking the difference of multiple columns in a file from a value from a single row..so far i have a loop to do that.. all the data is floating point..fin has the difference between array1 and array2..array1 has 700 x 300= 210000 values and array2 has 700 values.. ... (11 Replies)
Discussion started by: npatwardhan
11 Replies

2. UNIX for Dummies Questions & Answers

Date Calculations

I need to be able to use the current date and calculate 7 days ago to be stored in another variable to be passed to a file in my Unix shell script. I need the date in the following format: date '+%m/%d/%Y' or 05/16/2006 How do I calculate date minus 7 days or 1 week ago? (8 Replies)
Discussion started by: mitschcg
8 Replies

3. Shell Programming and Scripting

Need help with Date calculations in ksh

Hi Gurus, I am writing a script where we enter two dates, one a FROM DATE and the other a TO DATE. I need to validate that difference between the two dates is always less than or equal to 60 days. I could not find any date utility in ksh that could help me with this. Finally, I am deciding... (5 Replies)
Discussion started by: jidsh
5 Replies

4. Shell Programming and Scripting

Sed or awk script to remove text / or perform calculations from large CSV files

I have a large CSV files (e.g. 2 million records) and am hoping to do one of two things. I have been trying to use awk and sed but am a newbie and can't figure out how to get it to work. Any help you could offer would be greatly appreciated - I'm stuck trying to remove the colon and wildcards in... (6 Replies)
Discussion started by: metronomadic
6 Replies

5. Shell Programming and Scripting

bash script range calculations

Hi, I have data in the following form: AB001 10 AB002 9 AB003 9 etc AB200 5 What I need to do is sum up the second value according to groups of the first, i.e. AB001 to AB030 the total being X, AB031 to AB050 the total being Y etc (there are 5 AB ranges of different sizes). I'm sure... (3 Replies)
Discussion started by: chrissycc
3 Replies

6. Shell Programming and Scripting

Help with Arithmetic calculations in Shell script

Hi, I need a help with arithmetic calculations in my script. I have two variables: a=17; b=1712 I want to perform ($a/$b)*100 with two decimals in the result. I tried with following: res=$((100*a/b)) res=`echo "scale=2; $a / $b" | bc` But I am not getting the decimal values.... (4 Replies)
Discussion started by: karumudi7
4 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

Script to determine Date,TotalFile,total size of file based on date

I have file listed like below -rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz -rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz -rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz -rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz -rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz I... (5 Replies)
Discussion started by: krish2014
5 Replies

9. Shell Programming and Scripting

Filter on one column and then perform conditional calculations on another column with a Linux script

Hi, I have a file (stats.txt) with columns like in the example below. Destination IP address, timestamp, TCP packet sequence number and packet length. destIP time seqNo packetLength 1.2.3.4 0.01 123 500 1.2.3.5 0.03 44 1500 1.3.2.5 0.08 44 1500 1.2.3.4 0.44... (12 Replies)
Discussion started by: Zooma
12 Replies

10. Shell Programming and Scripting

Date wise calculations?

POST_DATE CHECK_NUMBER TYPE LOGIN_NAME 2015.09.09 XXXXXXXXXX mark XXXXXXXXXX 2015.09.09 XXXXXXXXXX fsadf XXXXXXXXXX 2015.10.05 XXXXXXXXXX defaa XXXXXXXXXX 2015.10.05 XXXXXXXXXX dewe XXXXXXXXXX 2015.10.06 XXXXXXXXXX dqwe XXXXXXXXXX 2015.09.14 XXXXXXXXXX dt4e XXXXXXXXXX... (22 Replies)
Discussion started by: nikhil jain
22 Replies
lchage(1)						      General Commands Manual							 lchage(1)

NAME
lchage - Display or change user password policy SYNOPSIS
lchage [OPTION]... user DESCRIPTION
Displays or allows changing password policy of user. OPTIONS
-d, --date=days Set the date of last password change to days after Jan 1 1970. Set days to -1 to disable password expiration (i.e. to ignore --mindays, and --maxdays and related settings). Set days to 0 to enforce password change on next login. (This also disables password expiration until the password is changed.) -E, --expire=days Set the account expiration date to days after Jan 1 1970. Set days to -1 to disable account expiration. -i, --interactive Ask all questions when connecting to the user database, even if default answers are set up in libuser configuration. -I, --inactive=days Disable the account after days after password expires (after the user is required to change the password). Set days to -1 to keep the account enabled indefinitely after password expiration. -l, --list Only list current user's policy and make no changes. -m, --mindays=days Require at least days days between password changes. Set days to 0 or -1 to disable this requirement. If this value is larger than the value set by --maxdays, the user cannot change the pasword. -M, --maxdays=days Require changing the password after days since last password change. Set days to -1 to disable password expiration. -W, --warndays=days Start warning the user days before password expires (before the user is required to change the password). Set days to 0 or -1 to disable the warning. EXIT STATUS
The exit status is 0 on success, nonzero on error. NOTES
Note that "account expiration" (set by --expire) is distinct from "password expiration" (set by --maxdays). Account expiration happens on a fixed date regardless of password changes. Password expiration is relative to the date of last password change. libuser Nov 8 2012 lchage(1)
All times are GMT -4. The time now is 11:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy