Unix/Linux Go Back    


Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

remove the contents of a file

Solaris


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-24-2006
surjyap surjyap is offline
Registered User
 
Join Date: Sep 2005
Last Activity: 23 September 2009, 5:16 AM EDT
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
remove the contents of a file

Hi
Let say a flat file contains 1000 lines. The cursor is at the 530 line number.
Now I like to delete all the line at one ahot. how it can be done?
Sponsored Links
    #2  
Old Unix and Linux 02-24-2006
vino's Unix or Linux Image
vino vino is offline Forum Advisor  
Supporter (in vino veritas)
 
Join Date: Feb 2005
Last Activity: 12 March 2015, 5:33 AM EDT
Location: Sydney, Down Under
Posts: 2,848
Thanks: 0
Thanked 13 Times in 13 Posts
You want to empty the file ?

At the prompt give
Code:
> file.name

Within the editor (say vi), give
Code:
:g/.*/d

Sponsored Links
    #3  
Old Unix and Linux 03-02-2006
com2com com2com is offline
Registered User
 
Join Date: Feb 2006
Last Activity: 24 March 2009, 4:49 AM EDT
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by surjyap
Hi
Let say a flat file contains 1000 lines. The cursor is at the 530 line number.
Now I like to delete all the line at one ahot. how it can be done?

or u can type something like this:

# cat /dev/null > filename

where "filename" is the file u want to empty at one shot Linux
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to copy a file without remove the contents of the target file? ahmedamer12 UNIX for Dummies Questions & Answers 2 04-22-2011 05:19 PM
Remove lines based on contents of another file bashshadow1979 Shell Programming and Scripting 4 03-25-2009 12:32 PM
Compare two files and remove all the contents of one file from another royalibrahim Shell Programming and Scripting 3 11-17-2008 11:55 PM
Remove spaces from first field, and write entire contents into other text file carriehoff Shell Programming and Scripting 3 11-11-2008 01:45 PM
Query:just need to remove the contents of the file without deleting that namishtiwari Shell Programming and Scripting 3 02-04-2008 04:41 AM



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