Advertisement

04.15.2008 at 11:22AM PDT, ID: 23324696
[x]
Attachment Details

perl one liner -  loop through list

Asked by bt707 in Perl Programming Language

I have a file that has hundreds of user records in it which each user record is separated with a new line

I'm using a perl command such as

perl -n00e 'print if (/^gram-20020624|^gram-20020624:Support|^david-20010801c/)' list-file.txt

This command will pull out the user records for these 3 accounts
gram-20020624   gram-20020624:Support   david-20010801c

Problem I have is I have a few hundred of the records that I need to pull out and cannot put all of them on the line of the command.

I've tried to put the list of names in a file then create a small perl script and put the list in a array then do a foreach with it but it's not working.

The one liner I used above will pull out these 3 records and look like

david-20010801c: owner=david-20010801c status=enabled
 name=David Doe
 description=
 other owners=
 double book=yes
 aces=@@o^c^wdeic^g;@@o^a^rsf^g;@^a^sf^g;@^c^^g;@^p^r^g
 email=
 time zone=
 categories=
 character set=
 language code=en
 created=Mar 10, 2005 21:53:44 GMT
 last modified=Dec 04, 2005 02:37:42 GMT
 events last modified=Jun 29, 2006 16:23:32 GMT
 todos last modified=Mar 10, 2005 21:53:44 GMT
 deletelog last modified=Mar 10, 2005 21:53:44 GMT
 number of events=36
 number of tasks=0

gram-20020624: owner=gram-20020624 status=enabled
 name=gram Morgan
 description=
 other owners=
 double book=yes
 aces=@@o^c^wdeic^g;@@o^a^rsf^g;@^a^sf^g;@^c^^g;@^p^r^g
 email=
 time zone=
 categories=
 character set=
 language code=en
 created=Feb 21, 2007 15:20:18 GMT
 last modified=Feb 21, 2007 15:34:25 GMT
 events last modified=Dec 17, 2007 15:31:51 GMT
 todos last modified=Feb 21, 2007 15:20:18 GMT
 deletelog last modified=Aug 10, 2007 11:01:58 GMT
 number of events=33
 number of tasks=0

gram-20020624:Support: owner=gram-20020624 status=enabled
 name=Travel Schedule
 description=
 other owners=
 double book=yes
 aces=@@o^c^wdeic^g;@@o^a^rsf^g;@^a^rsf^g;@^c^^g
 email=
 time zone=America/Denver
 categories=
 character set=
 language code=en
 created=Feb 21, 2007 17:14:26 GMT
 last modified=Feb 21, 2007 22:32:40 GMT
 events last modified=Dec 10, 2007 17:20:28 GMT
 todos last modified=Feb 21, 2007 17:14:26 GMT
 deletelog last modified=Nov 02, 2007 19:44:39 GMT
 number of events=142
 number of tasks=0


can someone please show me a easy way to do this, I know it there's a simple way to do this but sure not getting it to work right.

Thanks,




Start Free Trial
[+][-]04.15.2008 at 11:29AM PDT, ID: 21361342

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 11:36AM PDT, ID: 21361397

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 11:42AM PDT, ID: 21361459

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 11:48AM PDT, ID: 21361526

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 11:52AM PDT, ID: 21361561

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 12:00PM PDT, ID: 21361646

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 12:08PM PDT, ID: 21361736

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04.15.2008 at 12:19PM PDT, ID: 21361854

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.15.2008 at 12:19PM PDT, ID: 21361858

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628