LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-02-2016, 05:24 AM   #1
Ris124
LQ Newbie
 
Registered: Dec 2016
Posts: 1

Rep: Reputation: Disabled
Unhappy Need to Find First Day of the month from the current date.


Hi There,

I am trying to find the first day from the current date of the month.

For Example:
If current date is 12/2/2016 then,
I should get 'Thu' (i.e first day of the month) as the output.

Thanks in Advance.
 
Old 12-02-2016, 05:39 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 19,378

Rep: Reputation: 3422Reputation: 3422Reputation: 3422Reputation: 3422Reputation: 3422Reputation: 3422Reputation: 3422Reputation: 3422Reputation: 3422Reputation: 3422Reputation: 3422
Sounds reasonable - let's see what you have tried.
 
Old 12-02-2016, 06:43 AM   #3
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 3,547

Rep: Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577
Quote:
Originally Posted by Ris124 View Post
Hi There,

I am trying to find the first day from the current date of the month.

For Example:
If current date is 12/2/2016 then,
I should get 'Thu' (i.e first day of the month) as the output.

Thanks in Advance.
Interesting. You do not want the date, but only the day of the week short form?
I am eager to see what you have tried.
 
Old 12-02-2016, 06:48 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 5,361
Blog Entries: 3

Rep: Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667Reputation: 2667
You might need some hints. The utility "date" has a good manual page and there you will find a section on date formats. There it is possible to choose how the date is presented, including whether it is just a day name.
 
Old 12-02-2016, 07:02 AM   #5
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by Ris124 View Post
Hi There,

I am trying to find the first day from the current date of the month.
Look at a calendar? Sorry, could not resist.

First day of the current month:
Code:
date -d "-1 month -$(($(date +%d)-1)) days"

Last edited by Habitual; 12-02-2016 at 07:04 AM.
 
Old 12-02-2016, 09:37 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,504

Rep: Reputation: 2062Reputation: 2062Reputation: 2062Reputation: 2062Reputation: 2062Reputation: 2062Reputation: 2062Reputation: 2062Reputation: 2062Reputation: 2062Reputation: 2062
It's actually pretty straightforward:
Code:
date -d "$(date +%B) 1" +%a
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find/display out last Friday's date of the month sunnysthakur Linux - General 11 03-29-2013 04:09 AM
how to get the first and the last day in the month with "date" command myhnet Linux - Newbie 9 06-16-2009 04:16 AM
How to Find: last login information in terms of year-month-date avklinux Linux - General 7 03-14-2009 07:43 PM
Multicount in PHP , displays visits on current day, week, month, year and total visit xbaez Programming 1 04-24-2005 03:50 AM
Starting day of month, month length chrisk5527 Programming 2 03-03-2004 05:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration