how to read file

1 view
Skip to first unread message

Ritesh

unread,
Dec 28, 2011, 10:50:54 AM12/28/11
to VGLUG
Hi All,

I've a file env.ini in the following format

[ENV_GROUP_LIST]
ENV_GROUP=TEST1
ENV_GROUP=TEST2
ENV_GROUP=TEST3


I want to read the file in a such a way that I get only TEST, TEST1,
TEST2 in a list format in a variable. I am trying to do it with the
help of awk. Any help will be greatly helpful.

Thanks
Ritesh

Dharmit Shah

unread,
Dec 28, 2011, 12:13:20 PM12/28/11
to vg...@googlegroups.com
Hi,

I copied this data in a file called f1 and did var=$(awk -F'=' '{print $2}' file)

Output of echo $var is TEST1 TEST2 TEST3. 

Is that the output desired by you?

Ritesh

--
Please read http://www.catb.org/~esr/faqs/smart-questions.html before posting.
You received this message because you are subscribed to the "Vibrant GNU/Linux User Group".
To stop receiving emails from this group, mail to VGLUG+un...@googlegroups.com
To post to this group, send email to VG...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/VGLUG



--
Regards

Dharmit Shah


Kr Shah

unread,
Dec 29, 2011, 12:24:10 AM12/29/11
to vg...@googlegroups.com, shahd...@gmail.com

And if u want to ignore the first line then,
use like var=$(awk -F'=' 'NR>=2{print $2}' file)

Thanks,
Karan Shah
Tata Consultancy Services
Cell:- 9909982010
Mailto: kr....@tcs.com
Website:
http://www.tcs.com
____________________________________________
Experience certainty.        IT Services
                       Business Solutions
                       Outsourcing
____________________________________________



From: Dharmit Shah <shahd...@gmail.com>
To: vg...@googlegroups.com
Date: 12/29/2011 04:38 AM
Subject: Re: [VGLUG] how to read file
Sent by: vg...@googlegroups.com


=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you


Ritesh

unread,
Dec 29, 2011, 5:14:28 AM12/29/11
to VGLUG
Thanks for reply.

I want the output like

TEST
TEST1
TEST2

So that I'can have these values in a variable then I can use it.

Actually in solris server I had the command like "pget.awk
SECTION=ENV_GROUP_LIST PARAM=ENV_GROUP..........

Do we have a similar kind of or another awk so that I get the similar
output.

Thanks
Ritesh

On Dec 28, 10:13 pm, Dharmit Shah <shahdhar...@gmail.com> wrote:
> Hi,
>
> I copied this data in a file called f1 and did *var=$(awk -F'=' '{print
> $2}' file)*
>
> Output of echo $var is TEST1 TEST2 TEST3.
>
> Is that the output desired by you?
>
>
>
>
>
> On Wed, Dec 28, 2011 at 9:20 PM, Ritesh <rpande...@gmail.com> wrote:
> > Hi All,
>
> > I've a file env.ini in the following format
>
> > [ENV_GROUP_LIST]
> > ENV_GROUP=TEST1
> > ENV_GROUP=TEST2
> > ENV_GROUP=TEST3
>
> > I want to read the file in a such a way that I get only TEST, TEST1,
> > TEST2 in a list format in a variable. I am trying to do it with the
> > help of awk. Any help will be greatly helpful.
>
> > Thanks
> > Ritesh
>
> > --
> > Please readhttp://www.catb.org/~esr/faqs/smart-questions.htmlbefore
> > posting.
> > You received this message because you are subscribed to the "Vibrant
> > GNU/Linux User Group".
> > To stop receiving emails from this group, mail to
> > VGLUG+un...@googlegroups.com
> > To post to this group, send email to VG...@googlegroups.com
> > For more options, visit this group athttp://groups.google.com/group/VGLUG
>
> --
> Regards
>
> Dharmit Shah <http://about.me/dharmit>- Hide quoted text -
>
> - Show quoted text -

Kr Shah

unread,
Dec 29, 2011, 5:21:26 AM12/29/11
to vg...@googlegroups.com, VGLUG

You can write like
for var in `awk -F"=" '{print $2}' file`
do
...
...
done

Thanks,
Karan Shah
Tata Consultancy Services
Cell:- 9909982010
Mailto: kr....@tcs.com
Website:
http://www.tcs.com
____________________________________________
Experience certainty.        IT Services
                       Business Solutions
                       Outsourcing
____________________________________________



From: Ritesh <rpan...@gmail.com>
To: VGLUG <vg...@googlegroups.com>
Date: 12/29/2011 03:44 PM
Subject: [VGLUG] Re: how to read file
Sent by: vg...@googlegroups.com





>- Hide quoted text -
--
Please read
http://www.catb.org/~esr/faqs/smart-questions.html before posting.

You received this message because you are subscribed to the "Vibrant GNU/Linux User Group".
To stop receiving emails from this group, mail to VGLUG+un...@googlegroups.com
To post to this group, send email to VG...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/VGLUG
Reply all
Reply to author
Forward
0 new messages