For Programmers: Free Programming Magazines  


Home > Archive > AWK > March 2006 > awk to separate records









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author awk to separate records
bshah@citadon.com

2006-03-29, 9:56 pm

Hi Gurus,
I have a file with following output:

test.log
xxxx Password expiration date: Tue Mar 27 09:00:59 PST 2007 Last
password change: Mon MAR 27 09:00:59 PST 2006

I need the output as:

xxxx | date: Tue Mar 27 09:00:59 PST 2007

I am trying with awk as below:
awk '{print $1, $4,$5,$6,$7,$8,$9,$10}' test.log
gives me the correct output but not sure how to get a separator
vertical bar ( | )
xxxx date: Tue Mar 27 09:00:59 PST 2007 -> output
xxxx | date: Tue Mar 27 09:00:59 PST 2007 -> Required output

Any help is greatly appreciated.
Regards
tester

Janis Papanagnou

2006-03-29, 9:56 pm

bshah@citadon.com wrote:
> Hi Gurus,
> I have a file with following output:
>
> test.log
> xxxx Password expiration date: Tue Mar 27 09:00:59 PST 2007 Last
> password change: Mon MAR 27 09:00:59 PST 2006
>
> I need the output as:
>
> xxxx | date: Tue Mar 27 09:00:59 PST 2007
>
> I am trying with awk as below:
> awk '{print $1, $4,$5,$6,$7,$8,$9,$10}' test.log
> gives me the correct output but not sure how to get a separator
> vertical bar ( | )
> xxxx date: Tue Mar 27 09:00:59 PST 2007 -> output
> xxxx | date: Tue Mar 27 09:00:59 PST 2007 -> Required output


Add the string constant "|" to be printed in your list...

awk '{print $1,"|",$4,$5,$6,$7,$8,$9,$10}'


Janis

> Any help is greatly appreciated.
> Regards
> tester
>

Grant

2006-03-29, 9:56 pm

On 29 Mar 2006 18:01:26 -0800, bshah@citadon.com wrote:

>Hi Gurus,
>I have a file with following output:
>
>test.log
>xxxx Password expiration date: Tue Mar 27 09:00:59 PST 2007 Last
>password change: Mon MAR 27 09:00:59 PST 2006
>
>I need the output as:
>
>xxxx | date: Tue Mar 27 09:00:59 PST 2007
>
>I am trying with awk as below:
> awk '{print $1, $4,$5,$6,$7,$8,$9,$10}' test.log
>gives me the correct output but not sure how to get a separator
>vertical bar ( | )
>xxxx date: Tue Mar 27 09:00:59 PST 2007 -> output
>xxxx | date: Tue Mar 27 09:00:59 PST 2007 -> Required output


awk '{print $1 " | " $4,$5,$6,$7,$8,$9,$10}' test.log

or use printf to define field widths if xxxx varies

Grant.
--
Memory fault -- brain fried
bshah@citadon.com

2006-03-30, 6:56 pm

> Add the string constant "|" to be printed in your list...
>
> awk '{print $1,"|",$4,$5,$6,$7,$8,$9,$10}'
>
>

Thanks Janis. That worked

tvsb

2006-03-31, 3:56 am

Dear tester and Janis,

I was wondering if you could help me. I want to set up a gmail account
using only three letters but the account set up states that you are
required to have 6 or more characters in your log in name. I really
need to have just this short email. Could you please advise me.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com