The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell script command lg123 UNIX and Linux Applications 3 04-11-2008 12:35 AM
Use ftp command in shell script infyanurag Shell Programming and Scripting 3 02-05-2008 05:06 AM
cd command is not working in my shell script amitrajvarma Shell Programming and Scripting 3 10-03-2007 02:04 AM
how to use cd command in shell script LAKSHMI NARAYAN Shell Programming and Scripting 3 09-09-2007 03:04 AM
vi command in shell script bryan UNIX for Dummies Questions & Answers 2 05-23-2006 04:51 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-28-2005
Registered User
 

Join Date: Oct 2005
Location: Kolkata
Posts: 8
Shell script command

Can any one tell me how can i delete all the content

of a file at one go using Vi editor ???

It's urgent
Reply With Quote
Forum Sponsor
  #2  
Old 11-28-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,695
Few ways actually...

I would go with this one for vi

Inside vi, issue these

Code:
:1
dG
:w
Reply With Quote
  #3  
Old 11-28-2005
Registered User
 

Join Date: Oct 2005
Location: Kolkata
Posts: 8
Thanx

It has worked Thanx a lot
Reply With Quote
  #4  
Old 11-29-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,014
or simply:
Code:
:%d
:w
Reply With Quote
  #5  
Old 11-29-2005
Registered User
 

Join Date: Nov 2005
Location: cyberjaya
Posts: 85
or simply

d <Shift g>
Reply With Quote
  #6  
Old 11-29-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,695
Quote:
Originally Posted by ashterix
or simply

d <Shift g>
That would be under the assumption that the cursor is at line 1.
Reply With Quote
  #7  
Old 11-29-2005
Just Ice's Avatar
Lights on, brain off.
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 629
you could also empty the file out before starting vi ...
Code:
echo > /dir/file; vi /dir/file
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:56 AM.


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

Content Relevant URLs by vBSEO 3.2.0