How to add day of week at the end of each line that shows the date?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to add day of week at the end of each line that shows the date?
# 1  
Old 11-13-2012
How to add day of week at the end of each line that shows the date?

I have a file that looks like:

Code:
file1:
www_blank_com 20121008153552
www_blank_com 20121008162542
www_blank_com 20121009040540
www_blank_com 20121009041542
www_blank_com 20121010113548
www_blank_com 20121011113551
www_blank_com 20121012113542

I want the new file to show the day of week at the end of each line:

Code:
file2:
www_blank_com 20121008153552 Monday
www_blank_com 20121008162542 Monday
www_blank_com 20121009040540 Tuesday
www_blank_com 20121009041542 Tuesday
www_blank_com 20121010113548 Wednesday
www_blank_com 20121011113551 Thursday
www_blank_com 20121012113542 Friday

i thought of using sed but then I got stuck, any help?
# 2  
Old 11-13-2012
Take a look at the following

Please see
Get Day of Week from date
# 3  
Old 11-13-2012
Using shell script:-
Code:
while read url ts
do
  dt=$( echo $ts | cut -c 1-8 )
  echo $url $ts $( date -d "$dt" +"%A" )
done < infile


Last edited by Yoda; 11-13-2012 at 04:24 PM.. Reason: Removed backticks
This User Gave Thanks to Yoda For This Post:
# 4  
Old 11-13-2012
perfect, thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to obtain a day of the week from the date?

I have a date in format YYYYMMDD, i need to get the day of the week from the given date. I am working in AIX system. ---------- Post updated at 09:59 AM ---------- Previous update was at 09:57 AM ---------- Tried to post sum of the thread's link from which i tried, but de rules didnt allow me... (9 Replies)
Discussion started by: baranisachin
9 Replies

2. Shell Programming and Scripting

Extract week start,end date from given date in PERL

Hi All, what i want to do in perl is i should give the date at run time .Suppose date given is 23/12/2011(mm/dd/yyyy) the perl script shold find week start date, week end date, previous week start date,end date,next week start date, end date. In this case week start date will be-:12/19/2011... (2 Replies)
Discussion started by: parthmittal2007
2 Replies

3. Shell Programming and Scripting

Displaying time left to end of day, week, month?

Hello, basically I'm looking after a way of showing how many time is left to the end the day, week, month... I can't seem to figure this out, so could one of you skilled guys tell me how should this be approached? Examples: Time left: Day: 12h 12m 11s Week: 4d 12h 12m 11s Month:... (4 Replies)
Discussion started by: TehOne
4 Replies

4. Shell Programming and Scripting

Finding Day of the week from date

I have a problem of Finding Day of the week from date, but i need to do it within awk On SOLARIS Input:20101007(YYYYMMDD) Output:Thursday kindly provide suggestions. Thanks in advance (8 Replies)
Discussion started by: junaid.nehvi
8 Replies

5. Shell Programming and Scripting

how to obtain date and day of the week from `date` command

Hi, does anybody know how to format `date` command correctly to return the day of the week? Thanks -A I work in ksh.... (1 Reply)
Discussion started by: aoussenko
1 Replies

6. Shell Programming and Scripting

Function to get day of week from YYYY-MM-DD date

Can't find out how to get the day of the week from a given date, anyone got a code snippet that could help please? Ta!! (4 Replies)
Discussion started by: couponmeup
4 Replies

7. 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
Login or Register to Ask a Question