deleting word from this point to end of file in VI


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers deleting word from this point to end of file in VI
# 1  
Old 06-22-2010
deleting word from this point to end of file in VI

Hi All

i need to delete a recurring word from point "n" till end of the file. there are other words in this file so i cannot use `dG`, can anyone help me out?

Kind regards

Brian
# 2  
Old 06-22-2010
Try

Code:
:n,$s/word//

If you want the whole line deleted, then

Code:
:n,$g/word/d

# 3  
Old 06-22-2010
wht u mean to say u only wnt to delete "n" from whole of ur file. and wht do u want to replace in place of n. it shud be space or what?

sed 's/n/ /'
# 4  
Old 06-22-2010
yes that does work, but what happens this is a one word file

eg:
egg
mayo
pop
egg
mayo etc...etc....

if i use this s/n// i just get left with a nasty space inbetween which makes the txtfile look ugly... is there a way to delete the word and the space it leaves behind?
# 5  
Old 06-22-2010
Try my second approach if inside vi.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to perform a hexdump using dd from start point to end point?

hi, I would like to ask or is it possible to dump a hex using dd from starting point to end point just like the "xxd -s 512 -l 512 <bin file>" I know the redirect hexdump -C but i can't figure it out the combination options of dd. Hope someone can share their knowledge.. Thanks in... (3 Replies)
Discussion started by: jao_madn
3 Replies

2. Shell Programming and Scripting

deleting the part of the file(overwrite) using start and end point

here is the contents of bigfile.sql CREATE TABLE `Table11` ( `id` int(11) NOT NULL , `entityName` enum('Lines','EndUsers') COLLATE utf8_unicode_ci NOT NULL, `parentAllianceMigrationProjectId` varchar(255) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=2000 DEFAULT CHARSET=utf8... (30 Replies)
Discussion started by: vivek d r
30 Replies

3. Shell Programming and Scripting

how to move a word to the end of file

Hey guys, I want move a specific word from the middle of the text and move it the end of the file, which means I want the word to be deleted from it's line and moved to the end of file. I know how to use sed for adding a word the end of file, but I don't know how to move words. tnx (2 Replies)
Discussion started by: Johanni
2 Replies

4. Shell Programming and Scripting

deleting blank lines ONLY at the end of the file

Hi Guys, I have a quetion which was already discussed in the forum, but for some reason all approches suggested fail for me. I have a file which have blank lines at the body of the text as well as at the end. I need to delete ONLY blank lines at the end. Unfortunatly the approach below does not... (5 Replies)
Discussion started by: aoussenko
5 Replies

5. Shell Programming and Scripting

Grepping from a point in a file to the end of the file

does any one know how to turn the equivalent of this command: awk '/2011 John Doe 8344/,0' /tmp/ops.log | egrep -c "received request" to something that would use egrep instead of awk? What the awk command does is, it searches the ops.log file for "2011 John Doe 8344". When it finds it,... (4 Replies)
Discussion started by: SkySmart
4 Replies

6. Shell Programming and Scripting

deleting the lines at the end of the file.

I have a text file with two coulmn first column is just used in to show the line number, these line number are not there in the real file. I want to delete the line 16(in this file) here, even tough there is no data inside it . this empty line is causing me a problem by throwing me garbage... (12 Replies)
Discussion started by: shashi792
12 Replies

7. UNIX for Dummies Questions & Answers

Grep the word at the end of the file

I need to grep the word "hello" in each and every file. This word will be placed either at the end of the file or before the end of the file. Ex: file1: file2: afdsaf dsfalk fdsa weruoi sdaf erwqiuo fsdaf ... (5 Replies)
Discussion started by: sivakumar.rj
5 Replies

8. UNIX for Advanced & Expert Users

Deleting end of line $ character in file

Hi, I've got a file where in the middle of the record is a $ end of line character, visible only when I open the file in vi and do :set list. How to I get rid of the character in the middle and keep it at the end. The middle $ character always appears after SW, so that can be used to tag it.... (3 Replies)
Discussion started by: bwrynz1
3 Replies

9. UNIX Desktop Questions & Answers

Deleting Junks at the end of each line in a file

Is there any way to delete the Junk Characters(Invalid Characters like ^,',",),(,&,# etc.,) at the end of each record in a file? I want to do this using a single line script. Thanks to all in advance!!! (5 Replies)
Discussion started by: dave_nithis
5 Replies

10. Shell Programming and Scripting

Deleting end line spaces for along file

How can i clear all space characteres for a long file at the end of each line? (3 Replies)
Discussion started by: osymad
3 Replies
Login or Register to Ask a Question