lukegjpotter
lukegjpotter

Reputation: 251

Extract the minute value from the date

I need to extract the minute value from the Linux "date" command. The online guides are really confusing. Can you help please?

Upvotes: 2

Views: 665

Answers (2)

Benj
Benj

Reputation: 32398

It sounds like you want:

date +%M

This will print just the minute value and you can assign it to a variable with:

dat=`date +%M`
echo $dat

Upvotes: 5

Akhil Thayyil
Akhil Thayyil

Reputation: 9403

You can try

 date +%M

For getting it directly .

or this

 date | awk '{print $4}' | cut -d ":" -f 2

for getting it indirectly

Upvotes: 0

Related Questions