hi
i am having text file like this
444 raju
666 ranga Clerk
999 rani officer
111 juhi
i want to get the out put as
444 raju NA
666 ranga Clerk
999 rani officer
111 juhi NA
pls help
hi
i am having text file like this
444 raju
666 ranga Clerk
999 rani officer
111 juhi
i want to get the out put as
444 raju NA
666 ranga Clerk
999 rani officer
111 juhi NA
pls help
One way:
awk 'NF<3{$3="NA"}1' file
use below:-
nawk '(NF<3) {$0=$0" NA" }1' input_file
BR
#! /bin/ksh
cat xyz | while read abc
do
col1=`echo $abc | awk '{print $1}'`
col2=`echo $abc | awk '{print $2}'`
col3=`echo $abc | awk '{print $3}'`
if [[ -z $col3 ]]
then
col3=NA
echo "${col1} ${col2} ${col3}" >> output
else
echo "${col1} ${col2} ${col3}" >> output
fi
done
awk '{ if ( NF != 3 ) print $0, "N/A"; else print $0;}' file
$sed -e 's/\([0-9]\+\) \([a-zA-Z]\+\)$/\1 \2 NA/g' filename