put string end of the line

I've a problem to put .h end of the line..below my input file
fg_a
bb
fg_b
bb
fg_c
bb
fg_d
aa
fg_f
ee

and i want the output file as below
fg_a.h
bb
fg_b.h
bb
fg_c.h
bb
fg_d.h
aa
fg_f.h
ee

awk '/_/{$0=$0".h"}1' file
sed '/_/s/$/.h/' file

my mistake some of the texts don't have underscore

cat yourtext | sed 's/\(.*\_.*\)/\1\.h/g'

1 Like
awk 'NR%2{$0=$0".h"}1'
or
 
awk 'length($0)>2{$0=$0".h"}1' 
1 Like
awk '{if(NR%2==1){print $0".h"} else {print $0}}' File_Name