suppose i have a file like
Code:
//file.c
main()
{
printf("pritf");
printf("nirpt");
printf("%p%r%i%n%t%f");
}
suppose i would like to convert all the instances of "printf" to "PRINTF", the command i issued was
Code:
$ cat file.c | tr 'printf' 'PRINTF'
this is the output i got
Code:
//FIle.c
maIN()
{
PRINTF("PRITF");
PRINTF("NIRPT");
PRINTF("%P%R%I%N%T%F");
}
but that was not the output i wanted. this is the output i wanted
Code:
//file.c
main()
{
PRINTF("pritf");
PRINTF("nirpt");
PRINTF("%p%r%i%n%t%f");
}
because, neither "FIle.c" is printf, and yet it got effected by tr and neither "maIN()" is "printf" , yet it too was effected...
how do i make tr identify the entire string and then make it replace it with the desired string, instead of letting each instance of a character in the string replaced?