GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Operating System  >  Shell Scripting
Go To First  |  Previous Question  |  Next Question 
 Shell Scripting  |  Question 15 of 47    Print  
How would you replace the n character in a file with some xyz?

  
Total Answers and Comments: 8 Last Update: December 14, 2009   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: shiv
 
sed 's/n/xyz/g' filename > new_filename

Above answer was rated as good by the following members:
jrgalaura
June 03, 2005 08:01:17   
shiv        

RE: How would you replace the n character in a file with some xyz?
sed 's/n/xyz/g' filename > new_filename
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
February 15, 2006 06:32:22   
sriku_u Member Since: October 2005   Contribution: 1    

RE: How would you replace the n character in a file wi...

vi file name

then go to command mode

s/n/xyz/g


 
Is this answer useful? Yes | No
July 10, 2006 11:00:48   
Madhukrishnan        

RE: How would you replace the n character in a file wi...
tail -1 sample.txt | sed 's/.$/xyz/'Check this
 
Is this answer useful? Yes | No
August 13, 2007 09:36:59   
Bala G        

RE: How would you replace the n character in a file wi...
using perl we can do.

perl -p -i -e "s/n/abc/g" file_name

 
Is this answer useful? Yes | No
November 07, 2007 04:42:58   
Pradeep Singh        

RE: How would you replace the n character in a file wi...
We can replace n characters by using the following command:
1 $s/./xyz/g
where 1 shows that the search string will start searching patterns from first line of the file.
'.' for any character.
g for global replacement.

 
Is this answer useful? Yes | No
May 30, 2008 02:24:37   
BUGME Member Since: May 2008   Contribution: 1    

RE: How would you replace the n character in a file with some xyz?
FOLLOWING IS THE ANSWER FOR REPLACING RANGE OF CHARACTERS IN A LINE OF FILE. HERE 5TH TO 10TH CHARACTERS IN THE FILE text.txt ARE REPLACED BY "XYZ"

cut -c5-10 text.txt | sed 's/^.*$/XYZ/g'

 
Is this answer useful? Yes | No
June 04, 2008 15:05:12   
Vivek12 Member Since: June 2008   Contribution: 3    

RE: How would you replace the n character in a file with some xyz?
search for the character n in filename and replace it with xyz.
sed 's/n/xyz/g' filename

 
Is this answer useful? Yes | No
December 14, 2009 15:39:54   
sham2sushil Member Since: December 2009   Contribution: 6    

RE: How would you replace the n character in a file with some xyz?
sed -i 's/<Search_word>/<Replacing_word>/g' <filename>

sed -i option will directly changed in the fine. no need to redirect the output and create the another file. Here "g" for globe change.

Shambhu

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2010 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape