Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Simple text file parsing?
Name: kagetto Date: January 18, 2004 at 11:13:58 Pacific OS: red hat 9 CPU/Ram: Athlon 1300mhz 512mb
Comment:
I need to parse a simple text file of the following format.
The file has a variable number of spaces between the email and username and may or may not have blank lines. I just need to run through it and store the email and username into variables so I can email that person and then loop through to the next email address. Thanks for any help.
Name: James Boothe Date: January 18, 2004 at 11:40:57 Pacific
Reply:
In the solution below, awk will process only lines that have 2 or more fields (delimited by any amount of white space) and field1 must contain an at-sign, and creates lines in the format of:
email=email@blah.com uname=username1
Then those lines are piped to a while-loop for processing.
awk '\ NF>1 && $1~"@" \ {print "email=" $1 " uname=" $2} ' infile.txt | while read line do eval $line echo "email=$email uname=$uname" # (generate mail here) done
0
Response Number 2
Name: kagetto Date: January 18, 2004 at 12:23:51 Pacific
Summary: Hi guys, I am very new to the shell scripting .... I have a text file with 5 columns and all colums are seperated by some spI need to capture all individual user information attributes seperately like...
Summary: Hi everyone, I have a question on shell scripting. I have simple text file say "abc.txt". This file contains four colums (and 10 rows lets say). First column is a string (one word) than 3 integer numb...
Summary: I have a customer with SCO Unix and Windows . He has is a program that can create a large textfile. What he will use this program for is to create a text file that will contain a large amount of cu...