Replacing string based on line number
You can specify line number in sed or NR (number of record) in awk.
awk 'NR==34 { sub("AAA", "BBB") }'
or use FNR (file number record) if you want to specify more than one file on the command line.
awk 'FNR==34 { sub("AAA", "BBB") }'
or
sed '34s/AAA/BBB/'
to do in-place replacement with sed
sed -i '34s/AAA/BBB/' file_name