Need help with "date" in ksh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help with "date" in ksh script
# 8  
Old 12-19-2016
With this sort of thing I like to just get epoch times for the dates I'm working with and then use simple integer math to navigate like this:

Code:
#!/bin/ksh

TEMP=/file/home/test.txt
trap "rm -f $TEMP" SIGHUP SIGINT EXIT

day=$(printf "%(%s)T" "last month")
to=$(printf "%(%s)T" "this month")

while [ $day -lt $to ]
do
   w=$(printf "%(%Y-%m-%d)T\n" \#$day)
   XXX=$(grep $w /honey/logs/statistics/s* | wc -l )
   echo "S" $w " :"$XXX >> $TEMP
   let day=day+60*60*24
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

How to fix this "Input is not UTF-8" while executing ksh script?

Hi, I have an automated script which have set of sqls but when i am trying to execute the automated script by using nohup command, it is throwing an error like "Input is not UTF-8" . And when i digged in to it, i am getting some "Â" character in the shell script. How to avoid this!? Thanks. (1 Reply)
Discussion started by: Samah
1 Replies

3. Shell Programming and Scripting

Purpose of "read" and "$END$" in ksh ?

Hi, Could anyone please shed some light on the following script lines and what is it doing as it was written by an ex-administrator? cat $AMS/version|read a b verno d DBVer=$(/usr/bin/printf "%7s" $verno) I checked that the cat $AMS/version command returns following output: ... (10 Replies)
Discussion started by: dbadmin100
10 Replies

4. Shell Programming and Scripting

ksh script that echo " please insert your name " and store the output to a login.log file.

Hello All Nice to meet you all here in this forum, it's my 1rst time here i'm asking about a little issue that i face i added a ksh script that echo " please insert your name " and store the output to a login.log file. the script is working fine with normal telnet but Xstart is not working... (8 Replies)
Discussion started by: islam.said
8 Replies

5. Shell Programming and Scripting

ksh-script "arithmetic syntax error" comparing strings

Hi all, I´ve already searched the forum but can´t find what i am doing wrong. I am trying to compare two variables using ksh under red hat. The error I get is: -ksh: .: MDA=`md5sum /tmp/ftp_dir_after_transfer | cut -d' ' -f1 ` MDB=`md5sum /tmp/ftp_dir_before_transfer | cut -d' ' -f1 `... (3 Replies)
Discussion started by: old_mike
3 Replies

6. Shell Programming and Scripting

Ksh script function, how to "EXIT 2" without killing the current process?

Hi, Using AIX 5.3 and Ksh. />ls -al /usr/bin/ksh -r-xr-xr-x 5 bin bin 237420 Apr 10 2007 /usr/bin/ksh /> I recently started working for a new employer. I have written UNIX K-Shell scripts for many years and have never had this particular issue before. Its perplexing me. I have... (2 Replies)
Discussion started by: troym72
2 Replies

7. AIX

xx=`date +"%a %b %d"`;rsh xxx grep "^$XX" zzz ?

AIX 4.2 I am trying to do an rsh grep to search for date records inside server logs by doing this : xx=`date +"%a %b %d"` rsh xxx grep "^$XX" zzz gives : grep: 0652-033 Cannot open Jun. grep: 0652-033 Cannot open 11. But if I do : xx=`date +"%a %b %d"` grep "^$XX" zzz it works... (2 Replies)
Discussion started by: Browser_ice
2 Replies

8. HP-UX

script running with "ksh" dumping core but not with "sh"

Hi, I have small script written in korn shell. When it is called from different script, its dumping core, but no core dump when we run it standalone. And its not dumping core if we run the script using "/bin/sh" instead of "ksh" Can some body please help me how to resolve this issue. ... (9 Replies)
Discussion started by: simhe02
9 Replies

9. UNIX for Advanced & Expert Users

add seconds to: date"|"time"|"HHMMSS

Hey all, I have a shell that invokes a AWK. In this AWK i want invoke a function that receives 3 parameters: date: 20080831 time: 235901 duration: 00023 that function receive this 3 parameters and sum to this value two more seconds: 2008083123590100025 Remember that in case that... (3 Replies)
Discussion started by: anaconga
3 Replies

10. Shell Programming and Scripting

ksh script as a login shell return "no controlling terminal"

I have created a ksh shell script and used it as a login shell for a user. </etc/passwd> lramirev:x:111:200:Luis:/export/home/menush:/usr/local/menush/menush My shell script is like this: </usr/local/menush/menush> #!/bin/ksh # if ] then . $HOME/.profile fi ... (8 Replies)
Discussion started by: lramirev
8 Replies
Login or Register to Ask a Question
SENDINPATHS(8)						    InterNetNews Documentation						    SENDINPATHS(8)

NAME
sendinpaths - Send Usenet Path: statistics via e-mail SYNOPSIS
sendinpaths [-cdhn] [-k keep-days] [-r report-days] [address [address ...]] DESCRIPTION
sendinpaths checks pathlog/path for ninpaths dump files, finds dump files generated in the past report-days days, makes sure they are valid by running ninpaths on each one and making sure the exit status is zero, and passes them to ninpaths to generate a cumulative report. By default, that report is mailed to the e-mail addresses configured at the beginning of this script (by default, only one address is configured: <top1000@anthologeek.net>) in order to supply the TOP1000 project with useful statistics. See <http://top1000.anthologeek.net/> for more information. When finished, sendinpaths deletes all dump files in pathlog/path that are older than keep-days days. For more information on how to set up ninpaths, see ninpaths(8). OPTIONS
-c When this flag is used, the report is also e-mailed, besides the default submission addresses or those given as command-line arguments, to the newsmaster's address set at configure time. -d Enables debug messages. -h Gives usage information. -k keep-days After having processed dump files, sendinpaths removes those that are older than keep-days days. The default is 0, that is to say to remove all dump files. Setting keep-days to another value can be useful for debugging purpose because it permits to keep a few dump files. -n Don't e-mail the report; instead, just print it to standard output. Don't delete old dump files. -r report-days Process dump files generated during the last report-days days. The default is 32, that is to say to process all the dump files that have been generated during the last 32 days (if, of course, they have not been deleted yet by a previous run of sendinpaths according to the value set by the -k flag). address ... E-mail the report to the mentioned address or addresses, instead of the default one. Several addresses can be used, separated by whitespace. For instance, for two adresses: sendinpaths pathsurvey@top1000.org top1000@anthologeek.net HISTORY
sendinpaths was written by Olaf Titz <olaf@bigred.inka.de>. $Id: sendinpaths.pod 9384 2011-12-25 20:57:03Z iulius $ SEE ALSO
ninpaths(8). INN 2.5.3 2012-06-15 SENDINPATHS(8)