Solved

get the day of week from Timestamp

Posted on 2013-11-01
2
308 Views
Last Modified: 2013-11-01
Hello,

I have a file name like in ABCD201310310545.tar.gz format which has like Timestamp at the end of file name.
I have to extract the Timestamp and get the day of the week (like Monday/Tuesday..) from it.
Can you please help me in getting to the unix script.

Thanks,
Nova
0
Comment
Question by:Nova17
2 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 400 total points
Comment Utility
FILENAME="ABCD201310310545.tar.gz"
WEEKDAY=$(date -d "$(echo $FILENAME | awk -F"." '{print substr($1,length($1)-11,8)}')" "+%A")
echo $WEEKDAY

Open in new window

Your shell might not support $( ... ). If so, try this:

FILENAME="ABCD201310310545.tar.gz"
WEEKDAY=`date -d "\`echo $FILENAME | awk -F"." '{print substr($1,length($1)-11,8)}'\`" "+%A"`
echo $WEEKDAY

Open in new window

0
 

Author Closing Comment

by:Nova17
Comment Utility
cool.. thanks
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now