I could reformat the text.txt file into one line per record and use the ID to grep and combine the hits. I guess not very elegant and slow. I was also thinking of use a grep inside a while loop but I guess this would be slow too.
I was hoping to find an array solution but I would need some help:
Code:
awk 'FNR==NR{a[$1];next}{ for(i=1;i<=NF;i++){ if($i ~ "+" && $i in a) {print $i} else print $i} }' head.txt text.txt
thank you all for helping me to find three perfect solutions for my problem. @Aia, sorry if my description of the problem was not so clear.
Here the three solutions that worked for me:
Code:
time awk 'FNR==NR {h["+" $1]=$2;next} $1 in h {print $0, h[$1]; getline; print}' text.txt header.txt > outA.tmp
real 0m20.552s
user 0m17.823s
sys 0m2.697s
Code:
time awk '
NR == FNR {
i = substr($0,2);
getline;
A[i] = $0
next
}
$1 in A {
print "+" $0 RS A[$1]
}
' text.txt head.txt > outB.tmp
real 0m22.600s
user 0m19.482s
sys 0m3.078s
Code:
time awk 'FNR==NR {h[$1]=$2;next} $1 in h {print "+" $1, h[$1];print $2}' header.txt RS="+" text.txt > outC.tmp
real 1m29.579s
user 1m25.451s
sys 0m3.584s
Hi,
while running a program one of the command is creating a sub-shell which requires user inputs. Is there a way to bring the input prompt to a parallel session or an alternate way to input the values? the outer program doesn't allow to accept the parameter value for the command run in the sub... (8 Replies)
On a Solaris 9 system I had something happen to some of my interfaces; for some reason half of them went down. Since I have over 30 different Virtual IP's (or logical IP's) up on ce10 I don't want to take the time to find out which ones are up and which ones are down or even run the addif command... (2 Replies)
I have installed firefox and it previously worked before I installed the oracle software on my machine. Now when I click on the icon to bring up the browser it fails.
I tried to do it from the command line and this is what I get:
$ firefox
Cannot find mozilla runtime directory. Exiting
... (1 Reply)
Hi All,
I have a iplanet server running on solaris , i'm not able to start it using the start
Its giving following error
root@bld00: /usr/iplanet/servers6.1sp8/https-MLL-8.3dev # ./start
Sun ONE Web Server 6.1SP8 B06/13/2007 23:15
info: CORE5076: Using from
info: WEB0100: Loading web... (2 Replies)
The last thing I did was set REMOTE_LOGIN_PASSWORDFILE to EXCLUSIVE. Then rebooted server. Since that time I have not been able to login. During bootup it can't find root and generates alot of errors. Does anybody know of a default login and password that will allow me to log in and rebuild the... (2 Replies)
I have just installed solaris 10 on a sever .would appreciate if somebody can help me bringing up the GUI(basically i want to launch the browser) (1 Reply)
I have Linux 7.1 setup on a Dell and am unable to bring up any interfaces. Both the lo and eth0 fail upon boot up and I get a insmod error possibly due to bad irq or IO setting.
If I disable eth0 upon boot, then lo works fine, but offcourse I get the "delaying initialization" upon boot for eth0... (1 Reply)
Dear People
I have removed some of my files and directories( by using rm and rmdir commands) by mistake. I wish to bring them back. How is it possible?( I am using solaris 2.6)
best regards
Reza Nazarian:( (2 Replies)