Computing.Net > Forums > Unix > shell script

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.

shell script

Reply to Message Icon

Name: tinac
Date: October 27, 2007 at 08:25:25 Pacific
OS: solaris 9
CPU/Ram: ??
Product: ??
Comment:

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|902000025

Problem: 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!



Sponsored Link
Ads by Google

Response Number 1
Name: fpmurphy
Date: October 30, 2007 at 02:33:49 Pacific
Reply:

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.


0
Reply to Message Icon

Related Posts

See More


SCO Unix 5.0.5 lost root ... bash: /usr/sbin/ifconfig:...



Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: shell script

Shell Scripting www.computing.net/answers/unix/shell-scripting/8475.html

Variables in Shell SCripting www.computing.net/answers/unix/variables-in-shell-scripting/6020.html

shell script to uninstall java www.computing.net/answers/unix/shell-script-to-uninstall-java-/5976.html