Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a file that will eventually have thousands of rows with 2 columns on each row. The columns are fixed: 1st column has 6 digits, followed by a pipe separator, and 2nd column has 9 digits. It looks something like this:
column1|column2
ex:
900001|901000001
900002|901000003
900005|902000025Problem: It is possible that the number (value) in column1 may change. So, I need to update the file so that I always have the current number (value) in column1 for the number (value) in column2. If I don't have an occurrance of the column2 number I need to append a new row (column1|column2) to the file.
This needs to be automated... as it will be done many times. So, I need to pass the (unknown) values to the script, search the file, replace or append as needed, and save/close the file.
Any help offered will be greatly appreciated!

If you are always going to be searching on column 2, it would make sense to swap over the columns i.e. column2|column1.
If this file is going to grow into the thousands of rows, you would be better off writing a small C program to do the search and update.

![]() |
SCO Unix 5.0.5 lost root ...
|
bash: /usr/sbin/ifconfig:...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |