delete contents from command line


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers delete contents from command line
# 1  
Old 12-23-2003
delete contents from command line

How might I delete the contents of a file from the command line? (not delete the file)
# 2  
Old 12-23-2003
cat /dev/null > file-to-be-empty

And please use the search feature of this site to find your answers - this post would have given you everything you need to know (and the many ways of doing what you wanted to do).

Last edited by RTM; 12-23-2003 at 11:24 AM..
# 3  
Old 12-23-2003
one more way

echo "" >junk
Smilie

Regards
# 4  
Old 12-23-2003
:: cat /dev/null > file-to-be-empty

thank you


:: And please use the search feature of
:: this site to find your answers -
:: this post would have given you
:: everything you need to know (and the
:: many ways of doing what you wanted
:: to do

I did search first, but did not find the
answer in my result sets.

Thanks again.
# 5  
Old 12-23-2003
most fastest way

> filename
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to delete line from file using sed command?

hello Team, I want to delete below linux using sed command but I am getting error.sed -i '/url=/status.cgi?hostgroup=/d' 3 error:sed: -e expression #1, char 32: unknown option to `s' Could you please help me with correct syntax. My line contain / character because of that I am getting... (4 Replies)
Discussion started by: ghpradeep
4 Replies

2. Shell Programming and Scripting

sed command to grep multiple pattern present in single line and delete that line

here is what i want to achieve.. i have a file with below contents cat fileName blah blah blah . .DROP this REJECT that . --sport 7800 -j REJECT --reject-with icmp-port-unreachable --dport 7800 -j REJECT --reject-with icmp-port-unreachable . . . more blah blah blah --dport 3306... (14 Replies)
Discussion started by: vivek d r
14 Replies

3. UNIX for Dummies Questions & Answers

Need an awk command to delete a line

Hi all, As of now am using an awk command to check the number of columns in a file that has 10 lakh rows. Is it possible to remove that particular line having an extra column and copy the remaining lines to a new file ? YOUR HELP IS HIGHLY APPRECIATED. THANKS IN ADVANCE (5 Replies)
Discussion started by: Rahul619
5 Replies

4. Shell Programming and Scripting

sed command to delete everything after > on line

I have a large data file that I need to edit. There are lines like, > <IDNUMBER> (ST000002) > <SUPPLIER> (ST000002) > <IDNUMBER> (ST000004) > <SUPPLIER> (ST000004) and I need to delete everything after the >, excepting the end of line. > <IDNUMBER> > <SUPPLIER> > <IDNUMBER> > ... (4 Replies)
Discussion started by: LMHmedchem
4 Replies

5. Shell Programming and Scripting

using sed command to display contents where line numbers are stored in variables

if i want to display the contents of a file between say line number 3 and 10 then i use the following command sed -n '3,10p' filename if this 3 was contained in x and 10 was contained in y then how wud this command modified? sed -n '$x,$yp' filename does not work..please advise (2 Replies)
Discussion started by: arindamlive
2 Replies

6. Shell Programming and Scripting

sed command to delete line

HI, Im using the below commmand to delete lines having "(" at the start of a line. sed -e '/^(/d' But i need a command to delete lines that has only "(" in it and no other strings. infile - asdf asdf ( asdf ( asd outfile (1 Reply)
Discussion started by: dvah
1 Replies

7. Shell Programming and Scripting

SED delete only first line command - Help need

Can any one help me how the sed delete only first line command (D) works. sed -f sedcmds File.txt In this how the sed delete only first line command (D) works to delete the blank lines appearing more than ones leaving only one blank and deleting others blanks. While doing step by step when... (2 Replies)
Discussion started by: gwgreen1
2 Replies

8. UNIX for Dummies Questions & Answers

compare 2 file contents , if same delete 2nd file contents

Give shell script....which takes two file names as input and compares the contents, is both are same delete second file's contents..... I try with "diff"...... but confusion how to use "diff" with if ---else Thanking you (5 Replies)
Discussion started by: krishnampkkm
5 Replies

9. HP-UX

how to amount CD and see its contents in command line

if I insert the CD in HP Unix 11 how can I amount it and see its contents using command line ??? :confused: :confused: :confused: (2 Replies)
Discussion started by: KSA
2 Replies

10. UNIX for Advanced & Expert Users

Can't delete the user from command line

Hi All, I try from command line to delete a user (Solaris8) and I get the following error: UX: userdel: ERROR: Cannot update system files - loggin can not be deleted. Any suggestions will be helpful. The root (/) file system has enough free space. Regards, Slava (4 Replies)
Discussion started by: spavlov
4 Replies
Login or Register to Ask a Question