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.
how to read in an external text fil
Name: Matt Harrill Date: September 6, 2002 at 01:39:18 Pacific OS: NT CPU/Ram: P1/64k
Comment:
Hi
I have tried diff, and it does not give me what i need. I am unsure of the code needed to read in one line at a time of an external file and then use fields from that line to assign to variables. Those variables wold then be passed into an awk with the other file to be compared - can anybody help me please?
Name: tom z. Date: September 6, 2002 at 03:27:36 Pacific
Reply:
If you already know awk, then the most of the issue is solved. Just use awk to read in a line at a time and to assign the designate values to their respective variables.
Hope this helps, good luck.
0
Response Number 2
Name: James Boothe Date: September 6, 2002 at 06:46:22 Pacific
Reply:
Yes, instead of processing one line at a time and calling awk repeatedly, awk can read both of your files and do the diff logic. I could provide a solution if you provide more detail (sample from both files, how you want them matched, estimated file sizes).
But to answer your question, following code will read one line at a time from a file and assign fields to variables:
#!/bin/sh cat myinputfile | while read var1 var2 var3 remainder do echo "var1=$var1 var2=$var2 var3=$var3" done exit 0
Summary: Hello, I am new to UNIX. Now I am learning it. I dont know how to read txt files in UNIX system and edit. Please post the commands for read and edit with example. Thanks Jayaramgussy...
Summary: Can any one tell me how to find in which unix shell i am present using a shell script. I want it to find it programatically. Thanks in advance.. David Jeyam ...