2

I have a file with multiple records, given below is one such record.

APPLE,1527777000 

Here the second parameter is the date in long format. I want to convert this into date format. I have a command ssboetod for the same. Given below is the executed output for ssboetod.

ssboetod 1527777000 Thu May 31 20:00:00 2018 

I want the conversion to happen with awk command. Given below is the awk command used to just output the file records.

awk -F, '{print $1","$2}' <file> APPLE,1527777000 

Expected output with awk command is:

APPLE,Thu May 31 20:00:00 2018 

Looking for a awk command which will take the ssboetod command and give the expected output.

3
  • This might help: How can I convert timestamps in a column to a date? Commented Apr 27, 2018 at 5:55
  • 1
    Hope this helps ` awk -F, -v OFS=, '{converted=strftime("%a %B %d %T %Y",$2);$2=converted}1'` try playing with the formatters to get the exact results. Commented Apr 27, 2018 at 5:58
  • Thanks above command worked. Commented Apr 27, 2018 at 6:31

1 Answer 1

1
awk -F, -v OFS=, '{converted=strftime("%a %B %d %T %Y",$2);$2=converted}1' inputfile 

You can get more details about strftime function and its formatters from Here .

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.