Search Results

Search: Posts Made By: Harshal22
7,837
Posted By Don Cragun
Let's look at the code again in a slightly...
Let's look at the code again in a slightly different format:
1 awk -F "|" '
2 NR==FNR{
3 X[$1]=X[$1]?X[$1]"|"$2:$2
4 next
5 }
6 { if(X[$1]) print $0"|"X[$1]
7 else...
7,837
Posted By pamu
First we read fileB and stores it into array X[]....
First we read fileB and stores it into array X[].
Then we read second fileA and print array X[] with fileA.
7,837
Posted By pamu
Try awk -F "|"...
Try

awk -F "|" 'NR==FNR{X[$1]=X[$1]?X[$1]"|"$2:$2;next}{if(X[$1]){print $0"|"X[$1]}else{print $0"-"}}' fileB fileA
7,837
Posted By Don Cragun
awk -F "|" 'BEGIN { OFS = "|" } FNR == NR { ...
awk -F "|" 'BEGIN { OFS = "|" }
FNR == NR {
a[$1] = NF
for(i = 2; i <= NF; i++) a[$1,i] = $i
next
}
{ for(i = 2; i <= NF; i++) $i = a[$1,i] " -> " $i
...
7,837
Posted By rdrtx1
try: awk -F"|"...
try:
awk -F"|" 'NR==FNR{for(i=1;i<=NF;i++){a[$1,i]=$i;}; next;}{printf $1"|";for(i=2;i<=NF;i++){printf a[$1,i]" -> "$i (a[$1,(i+1)]?"|":"\n")}}' File1 File2
Showing results 1 to 5 of 5

 
All times are GMT -4. The time now is 08:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy