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 and shell scripting languages 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 04:35 AM
Use ftp command in shell script infyanurag Shell Programming and Scripting 3 02-05-2008 08:06 AM
cd command is not working in my shell script amitrajvarma Shell Programming and Scripting 3 10-03-2007 06:04 AM
how to use cd command in shell script LAKSHMI NARAYAN Shell Programming and Scripting 3 09-09-2007 07:04 AM
vi command in shell script bryan UNIX for Dummies Questions & Answers 2 05-23-2006 08:51 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-29-2005
dipanrc dipanrc is offline
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
  #2 (permalink)  
Old 11-29-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

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

I would go with this one for vi

Inside vi, issue these

Code:
:1
dG
:w
  #3 (permalink)  
Old 11-29-2005
dipanrc dipanrc is offline
Registered User
  
 

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

It has worked Thanx a lot
  #4 (permalink)  
Old 11-29-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
or simply:
Code:
:%d
:w
  #5 (permalink)  
Old 11-29-2005
ashterix ashterix is offline
Registered User
  
 

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

d <Shift g>
  #6 (permalink)  
Old 11-29-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

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

d <Shift g>
That would be under the assumption that the cursor is at line 1.
  #7 (permalink)  
Old 11-29-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
you could also empty the file out before starting vi ...
Code:
echo > /dir/file; vi /dir/file
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:45 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0