- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Unix scripting Date formating
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2002 08:31 AM
08-20-2002 08:31 AM
I want to get the seconds after midnight. in the format 'sssss. I have tried:
H=$(date +%H)
M=$(date +%M)
S=$(($H*60*60)+($M*60))
It gives seconds for an old time.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2002 08:44 AM
08-20-2002 08:44 AM
Re: Unix scripting Date formating
Something like that?
integer sec=0
integer sec1=0
integer sec2=0
integer Hour=$(date +%R | cut -d":" -f1)
integer Minute=$(date +%R | cut -d":" -f2)
(( sec1 = $Hour * 60 * 60 ))
(( sec2 = $Minute * 60 ))
(( sec = $sec1 + $sec2 ))
echo $sec
Regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2002 08:45 AM
08-20-2002 08:45 AM
Re: Unix scripting Date formating
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2002 08:46 AM
08-20-2002 08:46 AM
Re: Unix scripting Date formating
S = `exec $H \* 3600 + $M \* 60'
echo $S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2002 08:46 AM
08-20-2002 08:46 AM
Re: Unix scripting Date formating
Seconds are available:
S=S=$(date +%S)
Then:
# let X=\($H*3600\)+\($M*60\)+$S
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2002 08:47 AM
08-20-2002 08:47 AM
Re: Unix scripting Date formating
S = `exec $H \* 3600 + $M \* 60`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2002 08:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2002 08:49 AM
08-20-2002 08:49 AM
Re: Unix scripting Date formating
S=$((($H*60*60)+($M*60)))
The first $(( is for expressions calculation.
You need parenthesis to balance the formula.
-- Rod Hills