?
Solved

file

Posted on 2005-04-13
5
Medium Priority
?
156 Views
Last Modified: 2010-03-05
i have a file containing data in following format

email,username,date

i want to creat a file containing just the email address

i know how to do by opening file, reading .....

is there a simple way of doing that using some unix commands in my perl script
0
Comment
Question by:shahrahulb
  • 2
  • 2
5 Comments
 
LVL 20

Accepted Solution

by:
jmcg earned 1000 total points
ID: 13774625
If I read you correctly, you think you know how you'd do this in Perl, but you want to know how to do it externally to Perl using shell commands? Is that right?

system( "sed -e s/,.*// $existingfile >$newfile");

will trim out everything from the first comma to the end of the line on each line in the file named in $existingfile and place the results in a file named by $newfile.
0
 
LVL 1

Author Comment

by:shahrahulb
ID: 13774662
ya, u understood me correctly.....let me try this....
0
 
LVL 1

Author Comment

by:shahrahulb
ID: 13774686
It worked!!!!

thanks.
0
 
LVL 85

Expert Comment

by:ozo
ID: 13778091
But it won't work if you have a directory named "s" containing a directory that starts with ",."
0
 
LVL 20

Expert Comment

by:jmcg
ID: 13778294
Ozo's right, of course. Sloppy quoting on my part:

system "sed -e 's/,.*//' $existingfile >$newfile";
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question