Awk FNR==NR question

awk -F'[ =]' 'FNR==NR {a[$1]=$2; next} {$1=a[$1]} 1' $useralias ${entries} >> ${entries}_2

Hi,
Is there anyway to alter this command so that if it does not find a match it will just leave the line alone instead of replacing what it doesn't find with a blank space?

Try:

awk -F'[ =]' 'FNR==NR {a[$1]=$2; next} $1 in a{$1=a[$1]} 1' $useralias ${entries} >> ${entries}_2
1 Like

Yep, that seems to of done it alright... Many thanks for your help..

EDIT**

Actually one more thing.. $1 is referencing a command like the following

When I do the following awk command on a file for that line

awk -F= ' { print $2 } ' SUN_jd26_vintella.sudoers_cmndalias

I get that full line above which is what I want but if I run that

awk -F'[ =]' 'FNR==NR {a[$1]=$2; next} $1 in a{$1=a[$1]} 1' $useralias ${entries} >> ${entries}_2

it cuts off the stop part..

Not sure why

EDIT 2**
Meh, got it working by using the below..

awk -F'[ =]' 'FNR==NR {a[$1]=$2 " " $3; next} $1 in a{$1=a[$1]} 1' $useralias ${entries} >> ${entries}_2

Apologies for the double post here...

Is there a way though to anchor whats being replaced.. For example I'm replacing an alias called IBM with what it matches in the $cmdfile but its also replacing anything in the file with that contains IBM as part of its string..

awk -F'[ =]' 'FNR==NR {a[$1]=$2; next} $4 in a{$4=a[$4]} 1' $cmdalias ${entries} >> ${entries}_2

Could you give an example of input and desired output?