Sponsored Content
Top Forums Shell Programming and Scripting Reading in MM/DD/YY, find Day of Week Post 302910025 by Don Cragun on Tuesday 22nd of July 2014 05:35:51 AM
Old 07-22-2014
Quote:
Originally Posted by gjws
... ... ...

No, I did not try the example, I read it with my unqualified skill level and assumed it would simply return todays date. I should have actually taken the time to type this in to the terminal, when I did, it indeed returned what I needed.

... ... ...

Again thank you to everyone for you assistance, and apologies for my incorrect assumptions. Lesson learned, when you don't know what you are talking about (that's me!), it's best to shut up Smilie
We don't want you to shut up. We want you to learn. When you ask a question, and you get one or more suggestions; if you don't understand what it does:
  1. try it, or
  2. look at the man page for the suggested utility to see what it should do, or
  3. both.
And then:
  1. report back to us what happened,
  2. thank people who gave you working suggestions, or
  3. explain what you got and how that was different from what you were trying to do.
And, if you got something that works, but you can't figure out how it works, ask questions. Most of the volunteers who make suggestions here are happy to explain what their (or someone else's) code does. We want to help you learn how to make the most out of the tools that are available to you.

And, for other people reading this thread. If you wanted to do something like what was requested here on a system that doesn't have gawk and has a date utility that doesn't support the --date option, but you do have access to a 1993 or later version of the Korn shell (such as on Mac OS/X), you could also try:
Code:
#!/bin/ksh
while read d t v
do	printf '%s %-23s%-14s%(%A)T\n' "$d" "$t" "$v" "$d"
done < output

which with the given sample input file produces:
Code:
07/01/14 15:47:22               179.9500      Tuesday
07/01/14 16:03:29               3.9500        Tuesday
06/26/14 11:59:43               19.8000       Thursday
06/27/14 12:02:43               160.0000      Friday
07/02/14 13:12:35               5.9500        Wednesday
07/02/14 13:34:17               5.9500        Wednesday

This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Calculating the day of the week

Hi all, I would like to calculate the day of the week using a supplied date. i.e. 20011012 = Day 5. Any ideas? Many thanks, ligs (4 Replies)
Discussion started by: ligs
4 Replies

2. Programming

Function that gets the day of the week (0-6) ??

Hi , I am working at Unix system,using c lang. I need c fun which return the day of the week . For example : 0- Sunday. 1- Monday. .... 10x. (4 Replies)
Discussion started by: kamil
4 Replies

3. Shell Programming and Scripting

Yesterday's Day of week

I need o get yesterday's day of week but im not exactly sure. the actual name is what i want. I can do it with numbers but im not sure with words. (3 Replies)
Discussion started by: rcunn87
3 Replies

4. UNIX for Dummies Questions & Answers

Changing First Day Of The Week?

Hi All, Our system is running on Solaris 8 and we are using US locale. By default the First Day Of Week is Sunday, is it possible for us to change it to Monday? I have googled it but found very little of use. THanks in advance. (2 Replies)
Discussion started by: fowlerleftfoot
2 Replies

5. UNIX for Dummies Questions & Answers

How to find Day of the Week from the given date (Perl)?

How to find the Day of the Week of the given Date using perl? If I have a date in YYY--MM-DD format, how to find the DOW? Based on that, I need to find the following sunday. Pls help. (5 Replies)
Discussion started by: deepakwins
5 Replies

6. HP-UX

Get Day of Week from date

Hi All, I have date in string format 'YYYY-MM-DD'. I want to know day of the week for this date. Example. For '2005-08-21' my script should return '0' or Sunday For '2005-08-22' it should return '1' or Monday I want piece of code for HP-UX korn shell. Appreciate reply on this. (5 Replies)
Discussion started by: vpapaiya
5 Replies

7. UNIX and Linux Applications

How to find 'Day of week' in Linux system

Hi All, I want to find a day of week for the Linux system. can some one help me on this.. Thanks in advance, Raji. (2 Replies)
Discussion started by: rajinavaneethan
2 Replies

8. HP-UX

Find Day of Week

In HP-UX the date command does not have the "-d" switch like some other *nixes do. I'm working a simple script to tell me, given the day, month and year what day of the week that falls on. Assuming valid day, month and year input (I'd perform quality checks on the input separately, but not... (5 Replies)
Discussion started by: rwuerth
5 Replies

9. UNIX for Dummies Questions & Answers

Sudoers for one day per week?

I have been volunteered by my boss to be the sysadmin for our production redhat server. He asked me to tighten the security to avoid mishaps like "rm -f *" that occured not long ago. Right now, we have 53 users sudo-ing into the machine and it is an audit nightmare. I am wondering if it... (15 Replies)
Discussion started by: alan
15 Replies

10. Shell Programming and Scripting

Get the week's day

Hi All, I have the below requirement , if i give the week number for ex 41 i need to get the date for Monday and thursday for this given week. my expected output is 13/10/2014 (Monday's date) and 16/10/2014 (Thursday's date) I am using GNU LINUX . Pls help me with your thoughts. Thanks in... (7 Replies)
Discussion started by: mohanalakshmi
7 Replies
All times are GMT -4. The time now is 04:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy