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 04: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 Display Modes
  #1 (permalink)  
Old 11-28-2005
Registered User
 

Join Date: Oct 2005
Location: Kolkata
Posts: 8
Stumble this Post!
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 (permalink)  
Old 11-28-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,658
Stumble this Post!
Few ways actually...

I would go with this one for vi

Inside vi, issue these

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

Join Date: Oct 2005
Location: Kolkata
Posts: 8
Stumble this Post!
Thanx

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

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,002
Stumble this Post!
or simply:
Code:
:%d
:w
Reply With Quote
  #5 (permalink)  
Old 11-29-2005
Registered User
 

Join Date: Nov 2005
Location: cyberjaya
Posts: 85
Stumble this Post!
or simply

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

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,658
Stumble this Post!
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 (permalink)  
Old 11-29-2005
Just Ice's Avatar
Lights on, brain off.
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 629
Stumble this Post!
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
Display Modes




All times are GMT -7. The time now is 12:15 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