Hi
Does anyone know if awk as any function which works as instr() sql function?
for example
echo kk.FmB | awk '{print substr($0, 1+index($0, "."),3) }'
this returns FmB
but if the file name has more than 1 . then I would be screwed!
cheers
Printable View
Hi
Does anyone know if awk as any function which works as instr() sql function?
for example
echo kk.FmB | awk '{print substr($0, 1+index($0, "."),3) }'
this returns FmB
but if the file name has more than 1 . then I would be screwed!
cheers
try to use FS -> field separator and NF -> # of fields
echo abc.dfg.sss | awk -F. '{print $(NF), NF, FS}'
will print
sss 3 .
echo abc.dfg.sss | awk -F. '{print $(NF-1), NF, FS}'
will print
dfg 3 .
echo abc.dfg.sss | awk -F. '{print $(NF)}'
will print
sss