How can i check for a day


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How can i check for a day
# 1  
Old 06-24-2005
How can i check for a day

Hi,

When i tried this I am getting bad number
if [[ $(date '+%a') -eq Sat ]]; then now=saturday echo $now; else now=notsaturday echo $now; fi

How can i check for the same.

Thanks in advance
(I am new to Unix and so i raise some silly questions, please dont mistake me)
cheers,
gops
# 2  
Old 06-24-2005
$(date '+%a') = Sat
# 3  
Old 06-24-2005
MySQL

Use

if [[ $(date '+%a') = Sat ]]; then
now=saturday
echo $now
else
now=notsaturday
echo $now
fi

Note: -eq is meant for numeric comaprisions.
# 4  
Old 06-24-2005
Hi ,

With you people around , I think i can go for some complicated scripts.
I am really happy with the way I am getting the replies.

Thanks vgersh99 & Rishi (for correcting me about eq sign and for providing the solution).

cheers,
gops
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check day name is it saturday in bash shell script?

How to check the day name,is it saturday in bash shell script. If dayname = saturday then run the full load else run just the incremental loads end if Thank you very much for the helpful information. (4 Replies)
Discussion started by: cplusplus1
4 Replies

2. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

3. Shell Programming and Scripting

Writing a script to run weekly/monthly - check for weekday or day-of-the-month

Hi all, I currently have a UNIX file maintenance script that runs daily as a cron job. Now I want to change the script and create functions/sub inside it that runs on a weekly or monthly basis. To run all the scripts' daily maintenance, I want to schedule it in cron as simply maint.sh... (1 Reply)
Discussion started by: newbie_01
1 Replies

4. Shell Programming and Scripting

How to check xml file through out the day

Hi, I have a file with extension xml. So i need to search for this file and sftp. This script has to run from 8.00am to 8.00pm and during this when ever a file with *.xml exists in a particular directory , it has to sftp that file. How can i make script check for this file through out the... (2 Replies)
Discussion started by: krishna_gnv
2 Replies

5. Shell Programming and Scripting

Script to check if last modified day is previous day

Hi, I would like to write a script that checks if a file ('counter') was modified the previous day, if so erase its contents and write 00000000 into it. For e.g. if the file 'counter' was last modified at 11.30pm on 24th May and the script runs at 12.15am of 25th May, it should erase it's... (1 Reply)
Discussion started by: hegdepras
1 Replies

6. Shell Programming and Scripting

Script to check for the newest file mutiple times a day and SCP it to another server.

Hi, I need a sample of a script that will check a specific directory multiple times throughout the day, and scp the newest file to another server. Example: current file is misc_file.txt_02272011 (the last part is the date), once that has been secure copied, another one may come in later the... (1 Reply)
Discussion started by: richasmi
1 Replies

7. Shell Programming and Scripting

Script to find previous month last day minus one day timestamp

Hi All, I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this. My Requirment is as below: Input for me will be 2000909(YYYYMM) I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Discussion started by: girish.raos
3 Replies

8. Shell Programming and Scripting

Check File Exists and compare to previous day file script

We have data files that are ftp'd every morning to a SUN server. The file names are exactly the same except for that each has the date included in its name. I have to write script to do 2 things: STEP 1) Verify that the file arrived in morning. STEP 2) Compare the file size of the current... (3 Replies)
Discussion started by: rbknisely
3 Replies

9. Shell Programming and Scripting

Check if a day eg: saturday is the Last saturday of the month!

Hi, I need to develop a script to check for the day. If the day is a Saturday then the script should check if the Saturday is the last Saturday of the month so that certain set of instruction can be executed is it is the last Saturday. I do not want to use the crontab as this needs to be part... (9 Replies)
Discussion started by: jobbyjoseph
9 Replies

10. Shell Programming and Scripting

Write a shell script to find whether the first day of the month is a working day

Hi , I am relatively new to unix... Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell.. This is very urgent. Thanks for ur help... (7 Replies)
Discussion started by: phani
7 Replies
Login or Register to Ask a Question