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, 04: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, 04:39 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,422

Rep: Reputation: 4199Reputation: 4199Reputation: 4199Reputation: 4199Reputation: 4199Reputation: 4199Reputation: 4199Reputation: 4199Reputation: 4199Reputation: 4199Reputation: 4199
Sounds reasonable - let's see what you have tried.
 
Old 12-02-2016, 05:43 AM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 6,282

Rep: Reputation: 3002Reputation: 3002Reputation: 3002Reputation: 3002Reputation: 3002Reputation: 3002Reputation: 3002Reputation: 3002Reputation: 3002Reputation: 3002Reputation: 3002
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, 05:48 AM   #4
kakistocrat
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,756
Blog Entries: 4

Rep: Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972Reputation: 3972
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, 06: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 06:04 AM.
 
Old 12-02-2016, 08:37 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,828

Rep: Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243Reputation: 2243
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 03:09 AM
how to get the first and the last day in the month with "date" command myhnet Linux - Newbie 9 06-16-2009 03:16 AM
How to Find: last login information in terms of year-month-date avklinux Linux - General 7 03-14-2009 06:43 PM
Multicount in PHP , displays visits on current day, week, month, year and total visit xbaez Programming 1 04-24-2005 02:50 AM
Starting day of month, month length chrisk5527 Programming 2 03-03-2004 04:03 PM

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

All times are GMT -5. The time now is 09:56 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