The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Delete a word and complete line Aejaz UNIX for Advanced & Expert Users 1 05-02-2008 12:50 PM
how to delete spaces around a word sachin.gangadha UNIX for Dummies Questions & Answers 8 12-05-2007 04:00 AM
Delete all occurence of a word in one shot namishtiwari Shell Programming and Scripting 6 08-24-2007 08:41 AM
Can a shell script pull the first word (or nth word) off each line of a text file? tricky Shell Programming and Scripting 5 08-17-2006 06:29 AM
Sed help to delete everything prior to WORD drheams Shell Programming and Scripting 2 12-09-2005 05:34 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-04-2008
ntgobinath ntgobinath is offline
Registered User
  
 

Join Date: May 2008
Posts: 38
How to delete a word from a file?

Hi All,

I want to delete a word from file. How to do that.

I have file that contains the following Information.

EntityName:alba00r1.mis.amat.com OverallStatus:Minor IfName:Gi1/0
EntityName:alba00r1.mis.amat.com[ 0 [ 4 ] ] OverallStatus:Normal IfName:Se0/0/0
EntityName:alba00r1.mis.amat.com[ 0 [ 1 ] ] OverallStatus:Minor IfName:Gi0/0
EntityName:alba00r1.mis.amat.com[ 0 [ 2 ] ] OverallStatus:NotMon IfName:Gi0/1
EntityName:alba00r1.mis.amat.com[ 0 [ 3 ] ] OverallStatus:NotMon IfName:Tu0
EntityName:alba00r1.mis.amat.com[ 0 [ 14 ] ] OverallStatus:Normal IfName:Tu1
EntityName:alba00r1.mis.amat.com[ 0 [ 15 ] ] OverallStatus:Normal IfName:Lo0
EntityName:alba00r1.mis.amat.com[ 0 [ 16 ] ] OverallStatus:Normal IfName:Gi1/0.2

By using a command (without vi), I have delete a words (EntityName: and OverallStatus: and IfName

Thanks in Advance,
Gobinathan.S
  #2 (permalink)  
Old 06-04-2008
cooldude cooldude is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 44
Here's what I did:
Code:
sed 's/EntityName//' asdf | sed 's/OverallStatus//' | sed 's/IfName//'
where asdf is the file.
  #3 (permalink)  
Old 06-04-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 741
Code:
awk '{gsub(/(EntityName|OverallStatus|IfName):/,""); print}' file

sed -e 's/EntityName://g' -e 's/OverallStatus://g' -e 's/IfName://g' file
  #4 (permalink)  
Old 06-04-2008
ntgobinath ntgobinath is offline
Registered User
  
 

Join Date: May 2008
Posts: 38
Thanks for all your help. It's worked.
  #5 (permalink)  
Old 06-04-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,794
With perl:

Code:
perl -i.bck -ple's/(?:(?:Entity|If)Name|OverallStatus)://g' input
Sponsored Links
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 07:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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