![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| changing permission using FTP | panknil | Shell Programming and Scripting | 3 | 11-07-2007 08:08 PM |
| Changing userID and Changing group and GID | deal732 | Shell Programming and Scripting | 2 | 04-18-2007 11:09 AM |
| Changing the order using sed | venu_nbk | UNIX for Dummies Questions & Answers | 9 | 07-29-2006 06:03 PM |
| Changing Users | Bab00shka | Shell Programming and Scripting | 2 | 08-01-2003 05:44 AM |
| Changing IP's | Hordak | UNIX for Dummies Questions & Answers | 2 | 08-03-2002 01:42 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hello there, Here is (a part) of the file I want to change. Note the three spaces before the "3" (could be "2" or "0" also). Code:
3 621530 1.1935E-02 631530 1.1293E+01 641530 1.1117E-02 571540 4.4419E-14 3 581540 2.6670E-10 591540 3.8610E-09 601540 1.1016E-06 611540 3.2618E-06 3 611541 6.5572E-07 621540 9.8307E+00 631540 3.1177E+00 641540 1.4615E+00 3 571550 0.0000E+00 581550 8.8139E-12 591550 1.0739E-09 601550 2.5639E-07 3 611550 1.1011E-06 621550 3.6787E-05 631550 3.4821E+00 641550 3.1855E+00 3 641551 0.0000E+00 581560 9.4585E-13 591560 7.5358E-11 601560 1.2023E-07 3 611560 1.7968E-07 621560 5.4237E-04 631560 3.0054E-02 641560 6.5687E+00 3 581570 2.3926E-14 591570 9.9322E-12 601570 4.3929E-09 611570 4.6793E-07 3 621570 5.5911E-06 631570 6.3564E-04 641570 3.2355E+00 591580 2.8608E-13 I want to find some ID (eg. 621530) and change the value following it. I am using this script: Code:
VALUE=".........."
awk -v var="$VALUE" 'BEGIN{}
NR==FNR{a[$0]=$0; next}
{for(i=2;i<9;i+=2)if($i in a){$(i+1)=var}}
#{$1=" "$1}
{print}' ID_to_be_changed my_file
The problem is that it removes the three spaces in front of the row if it changes something in the row...removing the commented line solves the problem. However I do not know how to keep the same number of spaces between the rows: 2 spaces between the ID and the following value, and 1 space between a value and the ID after that (the script above turns everything into a single space). Can someone help me? |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|