In article <48********@127.0.0.1>, George <@wrote:
>There is a file name file.txt with content below:
11 21 31 41
41 31 21 11
31 21 11 41
>How can I read the file line by line, and then print the first three
columns(separed by tab)?
awk or perl would probably work well for this kind of application.
Your question is ambiguous; I see at least three possible
meanings:
1) print all of the members of the first column, *across*,
then print a tab, then print all of the members of the second
column *across*, then a tab, then all of the members of the
third column (still *across*.)
2) similar to the above, but with tabs between all the values
3) print the first member of the first column, then a tab,
then the first member of the second column, then a tab,
then the first member of the third column, then a newline,
print the second member of the first column, then a tab,
then the second member of the second column, then a tab,
then the second member of the third column, then a newline,
and so on, proceeding down the columns.
Also, it is ambiguous as to whether for some reason you need to
read the entire file before starting the printing, or if it would
be acceptable to print as you go.
--
"Nothing recedes like success." -- Walter Winchell