How would you replace the n character in a file with some
xyz?

Answers were Sorted based on User's Feedback



How would you replace the n character in a file with some xyz?..

Answer / ram

* sed 's/n/xyz/g' filename > new_filename
s -search and replace
n -character to be replaced
xyz - character to replace
g -global

* vi filename
:%s/n/xyz/g --search and replace
:w! ---save

Is This Answer Correct ?    8 Yes 0 No

How would you replace the n character in a file with some xyz?..

Answer / vipul dalwala

sed -i 's/n/xyz/g' filename

Is This Answer Correct ?    3 Yes 0 No

How would you replace the n character in a file with some xyz?..

Answer / viswa

In Vi editor,:%s/n/xyz/g

Is This Answer Correct ?    2 Yes 0 No

How would you replace the n character in a file with some xyz?..

Answer / sasmita

:1,$ s/n/xyz/g

Is This Answer Correct ?    1 Yes 0 No

How would you replace the n character in a file with some xyz?..

Answer / seshadri sethi

sed ’s/n/xyz/g’ filename > new_filename



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 replacemet.

Is This Answer Correct ?    1 Yes 0 No

How would you replace the n character in a file with some xyz?..

Answer / suresh raju

sed 's/.\{1,75\}/xyz/g' filename

here n=75. so 75 characters will be replaced with xyz

Is This Answer Correct ?    1 Yes 0 No

How would you replace the n character in a file with some xyz?..

Answer / tony

cat filename | sed 's/n/xyz/g' > newfile

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Shell Script Interview Questions

How can I Debug a shell scripts and Perl scripting?? or How do you debug a shell scripting and perl scripting ( at the compile time error or run time error) in Unix environment ?

4 Answers  


Explain about the exit command?

0 Answers  


Write a shell script in Linux to shift all characters in a file forward by five characters. (Thus “a” becomes “f’”).

2 Answers   Ignou, Tripura Info,


what is the difference between cmp and diff commands

2 Answers   Amazon, CTS,


How to take input values from the user?

4 Answers  






Explain about the slow execution speed of shells?

0 Answers  


What is path in shell script?

0 Answers  


What is console line?

0 Answers  


how to search for vowels a,e,i,o,u appearing in the same sequence in a file

4 Answers   Amazon,


Tell something about the super block in shell scripting?

0 Answers  


Hi, all Scripting professional. Q. I have written script1.sh and calling script2.sh in script1.sh file using bash shell as interpreter and my log in shell also bash shell.My code like Script1 #!/bin/bash echo "My script2 call" . script2.sh Here script2.sh file run successfully but when I have changed my interpreter bash to ksh like #!/bin/ksh Error are comming script2.sh command not found. Guid me how to call other script in our main script.

2 Answers  


What's the difference between scripting and coding?

0 Answers  


Categories