I need to find first daty of each month. What will I see on AIX "1" or "01"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I need to find first daty of each month. What will I see on AIX "1" or "01"
# 1  
Old 03-16-2017
I need to find first daty of each month. What will I see on AIX "1" or "01"

Could you please let me know the following? I have to find and check first day of each month. I do
Code:
 fdt=`date +%d`

will it give me on AIX
Code:
 "1" or "01"

I ask you because I couldn't make real test on first day and don't know

Thanks for contribution
# 2  
Old 03-16-2017
Code:
 fdt=`date +%d`
 
if [ $fdt -eq 1 ] ; then
    echo 'today is first day of month'
   
else
   echo 'today is not first day of the month'
fi

I am pretty sure this is not what you need. You need to explain what you want to accomplish. NOT how you want to do it. Why do I say this? Because the correct answer I gave is not very useful.
# 3  
Old 03-16-2017
I need on the first date of each month run the program, which is supposed to run first day of each month.

on AIX
Code:
 if [ $frst -eq 1 ]

will not work. It should be something like

Code:
 if [ "${frst}" = "1" ]
 then
       run the program
 else
      echo "Not the first date
 fi
  
 or 
  
 if [ "${frst}" = "01" ]
 then
       run the program
 else
      echo "Not the first date
 fi

I am not sure what it returns 1 or 01
# 4  
Old 03-16-2017
What I gave you will work in most shells, 01 does test as numeric 1.
Bash example:
Code:
$ f=01
$ echo $f
01
$ [ $f -eq 1 ] && echo 'works'
works

ksh example
Code:
$ f=01
$ echo $f
01
$ [ $f -eq 1 ] && echo 'works'
works

You may have to use something like
Code:
typeset -i frst

to force the frst variable to evaluate as an integer, in some old shells.

Since I do not know either your shell or its version I cannot help you any more than that.

Anyway, why do you not create a cronjob that executes on day one of any month?
crontab -e lets you edit your crontab
Ex: run at 10:10 only on the first
Code:
10 10 1 * *  /path/to/my/program.shl


Last edited by jim mcnamara; 03-16-2017 at 06:21 PM..
# 5  
Old 03-17-2017
Quote:
Originally Posted by digioleg54
I need on the first date of each month run the program, which is supposed to run first day of each month.
Wouldn't this be easier done using a cron-job?
This User Gave Thanks to rovf For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. 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

3. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

4. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

5. AIX

How to enable "TCP MD5 Signatures" and "https" on AIX?

I have searched many times but nothing found. Somebody help please :(:(:( (1 Reply)
Discussion started by: bobochacha29
1 Replies

6. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

7. Solaris

The slices "usr", "opt", "tmp" disappeared!!! Help please.

The system don't boot. on the screen appears following: press enter to maintenance (or type CTRL-D to continue)...I checked with format command. ... the slices "0-root","1-swap","2-backup" exist. ...the slises "3-var","6-usr" -unassigned. :( (16 Replies)
Discussion started by: wolfgang
16 Replies

8. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question