how you change xxxx_A to xxxx_B in awk

December 7, 2010 at 07:42:16
Specs: Windows Vista
am new to unix, can anyone help me

How can i convert xxxx_A to xxxx_B in awk


See More: how you change xxxx_A to xxxx_B in awk

Report •

#1
December 7, 2010 at 09:43:40
This changes every "A" to "B":

echo "xxxxx_A"| awk ' {
   gsub("A","B", $0)
   print $0
} '

and this regular expression changes only the "A" that ends the string:

echo "xxxxx_A"| awk ' {
   gsub("A$","B", $0)
   print $0
} '


Report •

#2
December 8, 2010 at 07:27:24
thank for the replay,but when i try like this it give me error

#!/bin/awk -f

count=gsub("A$","B", $0)
print count

this right. if it wrong how i write a in this format

thank you


Report •

#3
December 8, 2010 at 07:30:46
awk: ./Demo4:4: print count
awk: ./Demo4:4: ^ syntax error


this is the error i getting


Report •

Related Solutions

#4
December 8, 2010 at 07:36:23
thank you. i find out what is wrong

#!/bin/awk -f
{
gsub ("A$","B", $0)
print $0
}


Report •

Ask Question