![]() |
|
|
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 |
| replacing text in file1 with list from file2 | dovetail | Shell Programming and Scripting | 9 | 07-24-2008 02:20 AM |
| parsing file2 with input from file1 | forumsgr | Shell Programming and Scripting | 1 | 07-16-2008 07:09 AM |
| insert file2 after line containing patternX in file1 | repudi8or | Shell Programming and Scripting | 5 | 04-18-2008 02:35 PM |
| match value from file1 in file2 | myguess21 | Shell Programming and Scripting | 2 | 02-21-2008 11:39 AM |
| Awk Compare f1,f2,f3 of File1 with f1 of File2 | RacerX | Shell Programming and Scripting | 6 | 11-09-2007 01:34 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Thanks, i did try to solve it and did many searches here using keywords awk and compare. However, i kept screwing it up, am very confused at this point, and got nowhere and i really don't want to mess-up my 743,000 record database file, with something like:
Code:
FNR==NR { arr[$2]=$1; next}
$2 in arr { print arr[$1], $0 }
if (field1 of file2) == (field2 of file1) then
awk -F: 'FNR == NR {
{ f1[$2]=$1 $2
next;
}
if ($2 in f1) print f1[$1]$0; else print $0;}' ~/Desktop/file2.txt ~/Desktop/file1.txt > ~/Desktop/outputfile.txt
|
|
||||
|
Quote:
Quote:
Quote:
|
|
|||||
|
Quote:
Quote:
Quote:
![]() Your solution worked and is much more elegant than anything i was working on: Code:
awk -F':' 'NR==FNR{_[$2]=$1;next}$2 in _{$1=_[$2]}1' OFS=':' f2 f1
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|