The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with output of find command being input to basename command... new_learner UNIX for Dummies Questions & Answers 2 12-14-2008 02:56 AM
awk/sed Command : Parse parameter file / send the lines to the ksh export command rajan_san Shell Programming and Scripting 4 11-06-2008 01:29 PM
assign a command line argument and a unix command to awk variables sweta_doshi Shell Programming and Scripting 0 08-08-2008 06:54 AM
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 08:12 PM
inconsistent ls command display at the command prompt & running as a cron job rajranibl SuSE 5 07-30-2007 08:26 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-07-2009
c_d c_d is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 45
Exclamation tr command!

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?

Last edited by c_d; 03-07-2009 at 01:57 PM..
  #2 (permalink)  
Old 03-07-2009
c_d c_d is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 45
[SOLVED]

used sed -i s/printf/PRINTF/g filename instead...
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0