The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
delete n last lines of a file ncatdesigner Shell Programming and Scripting 7 05-17-2008 07:07 AM
delete first 100 lines from a file salaathi SUN Solaris 3 11-15-2007 12:01 AM
delete first 100 lines rather than zero out of file thepurple SUN Solaris 7 11-14-2007 09:35 AM
delete the lines from file sameersam Shell Programming and Scripting 2 04-03-2006 10:32 PM
Delete lines in a file umal Shell Programming and Scripting 6 02-08-2006 09:08 AM

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-10-2002
strok
Guest
 

Posts: n/a
delete all lines in file

how can i delete all lines in file by using "vi" ?
Forum Sponsor
  #2 (permalink)  
Old 03-10-2002
Registered User
 

Join Date: Feb 2002
Posts: 14
You can use following in escape mode to delete all lines from a file.

:1,$d
  #3 (permalink)  
Old 03-11-2002
Registered User
 

Join Date: Jan 2002
Location: Tampa
Posts: 5
Or, you could enter on line one:

dG

and that would delete to the end of the file.
  #4 (permalink)  
Old 03-11-2002
thehoghunter
Guest
 

Posts: n/a
If you want to delete ALL the lines, don't bother with vi.

$ cat /dev/null > /tmp/the-file-I-want-nothing-in.txt

This will keep you out of vi and delete all the lines.
  #5 (permalink)  
Old 03-11-2002
Registered User
 

Join Date: Jan 2002
Location: Tampa
Posts: 5
...Or if you're using ksh, the command

> /tmp/the-file-I-want-nothing-in.txt

will create a null file.
  #6 (permalink)  
Old 03-11-2002
Registered User
 

Join Date: Feb 2002
Posts: 28
touch a_new_empty_file.txt

will create a null file, or will change the last_access_time on that file.

> the_file_I_want_nothing_in.txt

will both empty a full file or create a null file. -mk
__________________
If it aint broke,
Fix it till it is.
  #7 (permalink)  
Old 03-11-2002
Registered User
 

Join Date: Mar 2002
Location: Buenos Aires, Argentina
Posts: 46
$ echo > file
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0