awk/perl script

nilesh vaghela nileshj.vaghela at gmail.com
Mon Jul 17 14:31:44 UTC 2006


you can use simple cut command too.

cut -d, -f(insert number of field like 1,3,4,5 etc} filename.

if it is online log file user tail and pipe the cut command.

On 7/17/06, Honti, Balázs <balazs at fmnet.hu> wrote:
>
> Hello!
>
> AWK does it for you, just have to count your columns, like this:
>
> awk -F, '{print $1,$2,$7,$(NF-2),$(NF-5)}' <in.txt >out.txt
>
> Your command should be this, if I also got the place of the 2 last columns
> backwards correctly, and you really have "," at the end of your lines.
> The output will be TAB separated, and includes the original double quotes,
> which I hope, you don't mind. if you do, ...|tr -d '"' >out.txt :-)
>
> Good luck,
> Balázs
> --
> > i want to a awk or perl script filter a file contains the following
> items
> >
> "Date","Time","RAS-Client","Record-Type","Full-Name","Auth-Type","User-Nam
> >
> e","NAS-IP-Address","NAS-Port",,,,,,,,,,"Login-IP-Host","Login-Service","L
> > ogin-TCP-Port","Callback-Number","Callback-ID",
> > "07/17/2006","07:35:43","WAN","Start","Unknown","Unknown","apmc","
> 10.16.0.
> > 2
> > ","20000","2","1",,,,,,,,,,,,,,,,,,"9560","53539180",
> > "07/17/2006","07:35:43","WAN","Start","Unknown","Unknown","aaac","
> 10.16.0.
> > 2
> > ","20000","2","1",,,,,,,,,,,,,,,,,,"9560","57532280",..............
> > ..................
> >
> > I want to have the layput as follow
> > Date  Time  Username  Phone_No.  IP_address
>
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request at redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
>



-- 
Nilesh Vaghela
ElectroMech
Redhat Channel Partner and Training Partner
74, Nalanda Complex, Satellite Rd, Ahmedabad
25, The Emperor, Fatehgunj, Baroda.
www.electromech.info


More information about the redhat-list mailing list