awk command
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > awk command




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    awk command  
pawan_test


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-21-06 10:56 PM

Hi all.,

i am working on script.

I have a file. i type ls -ltr and i get

-rwxrwx--- 1 pavi C2052EX 15 Mar 21 09:50
START.TTN.20060321.095017.ctl_20060321095032

( pls note everything is in 1 line, here it came in 2 lines.)

I have to use awk command and only get the MAR 21 to be displayed in
the out.it is tab delimited.

can anyone help me please how can i do it using awk

thanks
pavi






[ Post a follow-up to this message ]



    Re: awk command  
Pascal Bourguignon


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-21-06 10:56 PM

"pawan_test" <sridhara007@gmail.com> writes:

> Hi all.,
>
> i am working on script.
>
> I have a file. i type ls -ltr and i get
>
> -rwxrwx--- 1 pavi C2052EX 15 Mar 21 09:50
> START.TTN.20060321.095017.ctl_20060321095032
>
> ( pls note everything is in 1 line, here it came in 2 lines.)
>
> I have to use awk command and only get the MAR 21 to be displayed in
> the out.it is tab delimited.
>
> can anyone help me please how can i do it using awk

ls -ltr | awk '{printf "%s\t%s\n",$6,$7;}'

Note however that that date field in the output of ls can have
different formats.


--
__Pascal_Bourguignon__               _  Software patents are endangering
()  ASCII ribbon against html email (o_ the computer industry all around
/\  1962:DO20I=1.100                //\ the world http://lpf.ai.mit.edu/
2001:my($f)=`fortune`;          V_/   http://petition.eurolinux.org/





[ Post a follow-up to this message ]



    Re: awk command  
Rainer Temme


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-21-06 10:56 PM

pawan_test wrote:

> I have a file. i type ls -ltr and i get
> -rwxrwx--- 1 pavi C2052EX 15 Mar 21 09:50
> START.TTN.20060321.095017.ctl_20060321095032

> I have to use awk command and only get the MAR 21 to be displayed in
> the out.it is tab delimited.

How about

ls -ltr  | awk '{ printf("%s %s\n",$6,$7); }'

Rainer





[ Post a follow-up to this message ]



    Re: awk command  
pawan_test


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-21-06 10:56 PM

Hi Guys.,


thanks for the suggestions. both the suggestions are working.
ls -ltr | awk '{printf "%s\t%s\n",$6,$7;}'
ls -ltr  | awk '{ printf("%s %s\n",$6,$7); }'

when i execute the above command it gives me all the values in the
fields 6 and 7.
i am looking in the output to display only march 21. ( i.e today's
date) .
can you please give me a suggestion.

thanks
pavi






[ Post a follow-up to this message ]



    Re: awk command  
Pascal Bourguignon


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-21-06 10:56 PM

"pawan_test" <sridhara007@gmail.com> writes:

> Hi Guys.,
>
>
> thanks for the suggestions. both the suggestions are working.
> ls -ltr | awk '{printf "%s\t%s\n",$6,$7;}'
> ls -ltr  | awk '{ printf("%s %s\n",$6,$7); }'
>
> when i execute the above command it gives me all the values in the
> fields 6 and 7.
> i am looking in the output to display only march 21. ( i.e today's
> date) .
> can you please give me a suggestion.

Yes. Read:
man awk

--
__Pascal Bourguignon__                     http://www.informatimago.com/

PLEASE NOTE: Some quantum physics theories suggest that when the
consumer is not directly observing this product, it may cease to
exist or will exist only in a vague and undetermined state.





[ Post a follow-up to this message ]



    Re: awk command  
Jim Cochrane


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-21-06 10:56 PM

On 2006-03-21, pawan_test <sridhara007@gmail.com> wrote:
> Hi Guys.,
>
>
> thanks for the suggestions. both the suggestions are working.
> ls -ltr | awk '{printf "%s\t%s\n",$6,$7;}'
> ls -ltr  | awk '{ printf("%s %s\n",$6,$7); }'
>
> when i execute the above command it gives me all the values in the
> fields 6 and 7.
> i am looking in the output to display only march 21. ( i.e today's
> date) .
> can you please give me a suggestion.

Well, that's easy:

echo hi|awk '{ print "Mar\t21" }'

Or, if you want the current date if you run this tomorrow and beyond:

set $(date)
echo hi|awk '{ print "'$2'\t'$3'" }'

:-)

(Point of this satirical post: Providing a good specification for a problem
solution, even a seemingly simple one, is often difficult and requires great
precision.  You need more precision in your problem statement if you want
to cut down on the number of repetitions of: "Yes, that does xxx nicely,
but that's not what I asked for - I asked for yyy.")


--

*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.c
om ***





[ Post a follow-up to this message ]



    Re: awk command  
John W. Krahn


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-22-06 01:48 AM

pawan_test wrote:
>
> i am working on script.
>
> I have a file. i type ls -ltr and i get
>
> -rwxrwx--- 1 pavi C2052EX 15 Mar 21 09:50
> START.TTN.20060321.095017.ctl_20060321095032
>
> ( pls note everything is in 1 line, here it came in 2 lines.)
>
> I have to use awk command and only get the MAR 21 to be displayed in
> the out.it is tab delimited.
>
> can anyone help me please how can i do it using awk

You can do it in Perl:

perl -MPOSIX -le'print strftime( "%b\t%e", localtime +( stat
"START.TTN.20060321.095017.ctl_20060321095032" )[ 9 ] )'


John
--
use Perl;
program
fulfillment





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:32 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register