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

What is shell environment?

0 Answers  


Is bash an operating system?

0 Answers  


Is powershell a language?

0 Answers  


how to print the 2-d, 3-d arrays in unix shell script programs please answer thi questio to my mail venusaikumar@gmail.com

0 Answers  


Script S1 (which copies .dat files from one directory1 to another directory2) run continuously. Write Script S2 which kills S1 first, compresses all .dat files in directory1 and directory2 successfully, re-run Script S1 and stops self i.e. S2.

2 Answers   IBM, TCS,


Determine the output of the following command: [ -z “” ] && echo 0 || echo 1

0 Answers  


What does it mean to debug a script?

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,


State the advantages of shell scripting?

0 Answers  


c program which accept one argument as a directory name and prints all the file name along with its inode number and total count of the file in directory

1 Answers  


What are the advantages of shell script?

0 Answers  


Why should we use shell scripts?

0 Answers  


Categories