LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-21-2006, 03:26 AM   #1
sharad
Member
 
Registered: Dec 2005
Posts: 48

Rep: Reputation: 15
how to delete the contents of a file using shell scripts


Hi,
I want to delete some text from the file using shell script.
I am using redhat7.0 . Please help me to solve this problem.

thanks in advance.
 
Old 05-21-2006, 03:35 AM   #2
Linux~Powered
Member
 
Registered: Jan 2004
Location: /lost+found
Distribution: Slack`er-current
Posts: 845

Rep: Reputation: 31
You want to delete text from a text file? If so, you'll want to open and editor like vi or vim and delete the lines.

Code:
vi yourfile
To get a list of vi/vim commands visit this site. Hope that answered your question.
 
Old 05-21-2006, 04:54 AM   #3
robbbert
Member
 
Registered: Oct 2005
Location: Hannover, Germany
Distribution: Let there be Ubuntu... :o)
Posts: 573

Rep: Reputation: 32
Code:
> filename
 
Old 05-21-2006, 05:05 AM   #4
daihard
Member
 
Registered: Jul 2003
Location: Seattle, WA
Distribution: Kubuntu 12.04
Posts: 913

Rep: Reputation: 32
Quote:
Originally Posted by sharad
Hi,
I want to delete some text from the file using shell script.
I am using redhat7.0 . Please help me to solve this problem.
What kind of content deletion do you have in mind? Want the script to search and remove certain keywords? Or delete lines that include particular words? You need to be more specific if you want concrete help.
 
Old 05-22-2006, 04:45 AM   #5
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Sed is usually used for editing files. The name stands for Serial EDitor.
For tabular text, awk is often used.
 
Old 05-22-2006, 05:22 AM   #6
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Delete lines 1-6 from a file
Code:
sed '1,6d' oldfile > newfile
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unix shell script:How to delete the first line in a file?? rche3252 Programming 6 03-03-2010 07:32 AM
2 gigabyte /tmp directory..ok to delete contents pAn1k Linux - Newbie 3 09-02-2004 09:56 AM
How to delete a line from a text file with shell script programming Bassam General 1 01-28-2004 08:51 PM
Delete contents of the file, but not file? mikeshn Linux - General 9 05-28-2003 06:47 AM
Can't delete or list contents of an old kio_http cache,... JaseP Linux - General 3 06-09-2002 03:00 AM


All times are GMT -5. The time now is 07:54 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration