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

Devise a script that takes file name as arguement(which must present in the current directory)and locates from your home directory tree all thpath names of its links.Then mail the list to self.

0 Answers  


A file has multiple records each having three 30-bit long fields(field1,field2,field3).There is also a lookup file,LOOK_UP.dat.Now, we need to consider only the last ten digits of field1 and lookup the file LOOK_UP.dat. If there a match then field2 and field3 should replaced with corresponding data from the lookup file. otherwise that particular record,for which there is no match, should be stored in a seperate file.

2 Answers   Wipro,


How to declare functions in unix shell script?

4 Answers  


What is the difference between a variable and value?

7 Answers   Sun Microsystems,


How do I run a .sh file on mac?

0 Answers  






How do you print the output the same string which is typed in command line. how do you write the shell script or command for this. if i entered "Hello" in command line, it should print 'Hello', if i say "Hello Welcome", i should get the "Hello Welcome" as output.?

3 Answers   IBM, Symphony,


What is sed in shell script?

0 Answers  


What is the use of "$?" Sign in shell script?

0 Answers  


What is use of "cut" command?

3 Answers  


What is the default shell of solaris?

0 Answers  


What is the use of "shift" command in passing parameters?

1 Answers  


What is computer cli?

0 Answers  


Categories