out=split(FILENAME,a,"/")
sub(/\./,"",a[out])
sub(/\-/,"",a[out])
NEWSTRING="main_"a[out-1]"_"a[out]"(" # The word we want to insert
gsub(/main\(/,NEWSTRING); # the word to be replaced
print "Main becomes ",NEWSTRING")","in file ",FILENAME >> "/home/ds2/test/NEW2.txt"
print NEWSTRING")" >> "/home/ds2/test/MAIN2.txt"
print FILENAME >> "/home/ds2/test/NAME2.txt"
print $0 > FILENAME;
}' $FNAME
if the input size was more than 4K the function fails,,,, so pls any suggestions???
Depending on the OS gawk (GNU awk) handles longer lines, more fields, more records and bigger files and is compatible with awk. Take a look at: The GNU Awk User's Guide