Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1001153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:37:28+00:00 2026-05-16T07:37:28+00:00

So I need to convert a date to a different format. With a bash

  • 0

So I need to convert a date to a different format. With a bash pipeline, I’m taking the date from the last console login, and pulling the relevant bits out with awk, like so:

last $USER | grep console | head -1 | awk '{print $4, $5}'

Which outputs: Aug 08
($4=Aug $5=08, in this case.)

Now, I want to take ‘Aug 08’ and put it into a date command to change the format to a numerical date.

Which would look something like this:

date -j -f %b\ %d Aug\ 08 +%m-%d

Outputs: 08-08

The question I have is, how do I add that to my pipeline and use the awk variables $4 and $5 where ‘Aug 08’ is in that date command?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:37:29+00:00Added an answer on May 16, 2026 at 7:37 am

    You just need to use command substitution:

    date ... $(last $USER | ... | awk '...') ...
    

    Bash will evaluate the command/pipeline inside the $(...) and place the result there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 496k
  • Answers 496k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Suppose you have a solution a such that f(a) =… May 16, 2026 at 11:42 am
  • Editorial Team
    Editorial Team added an answer ActionScript must be using a different string encoding, but it… May 16, 2026 at 11:42 am
  • Editorial Team
    Editorial Team added an answer Try this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"… May 16, 2026 at 11:42 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Following from my last question which @Jon Skeet gave me a lot of help
For a huge number of huge csv files (100M lines+) from different sources I
I need to convert the text in the textbox of my xaml code to
I need to convert a navigable map to a 2D String array. Below given
I need to convert a string like this: A &#039;quote&#039; is <b>bold</b> into: A
I need to convert an integer into a base64-character representation. I'm using OxA3's answer
I'm trying to store today's date in a sqlite table as a string in
i need some advice and help with a plugin i am writing for Nagios.
It appears there are many ways to approach date and time massaging in php.
I have 2 integer fields that represent dates in the YYYYMMDD format. What is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.