|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Help on bash
Hi,
I have this simple awk script that cross-match 2 tables/files using for example their 3th columns awk '{v=FNR==1?"\n":$3} NR==FNR {a[v]=$3; b[v]=$0; next} v in a {print b[v],$0}' fileName1 fileName2 I would like to put this function into .bashrc function awkcrossmatch() { tmp=$1 awk '{v=FNR==1?"\n":$tmp} NR==FNR {a[v]=$tmp; b[v]=$0; next} v in a {print b[v],$0}' $2 $3 } Why this calling sequence doesnot work? awkcrossmatch '$3' fileName1 fileName2 How to write this properly? Thanks oliver |
|
#2
|
|||
|
|||
|
The awk string is in single quotes, so $tmp will not get replaced with the value you want. You would have to either use double quotes and escape the awk $ characters with backslashes, or build the string up by concatenating strings together.
|
|
#3
|
|||
|
|||
|
Quote:
I hope I understood correctly. I did this change function awkcrossmatch() { tmp=$1 awk "{v=FNR==1?"\n":\$tmp} NR==FNR {a[v]=\$tmp; b[v]=\$0; next} v in a {print b[v],\$0}" $2 $3 } But steel it does not work. |
|
#4
|
|||
|
|||
|
Bash? As in Linux Bash? You might want to move over to the linux forums
![]()
__________________
Did this post help? Please Click The Next To My PostNeed help? Did you try Google? Take a look over at my current work in progress http://crispycrisp.org |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Help on bash |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|