LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-25-2007, 08:38 AM   #1
luzner
LQ Newbie
 
Registered: Jul 2007
Posts: 2

Rep: Reputation: 0
how to cut exact words within a file


I am trying the following command to cut the exact word "NO" from the the following text file .


cat tmp1 |tr -d 'NO' >> files

INT_CELL_KVZ_CDR_001980_20070722224203.DAT NO
INT_MAPA_KVZ_CDR_000309_20070722224203.DAT NO
INT_CELL_KVZ_CDR_001981_20070723225049.DAT NO
INT_MAPA_KVZ_CDR_000310_20070723225053.DAT NO
INT_CELL_KVZ_CDR_001982_20070724225507.DAT NO
INT_MAPA_KVZ_CDR_000311_20070724225511.DAT NO


the output is :

IT_CELL_KVZ_CDR_001980_20070722224203.DAT
IT_MAPA_KVZ_CDR_000309_20070722224203.DAT
IT_CELL_KVZ_CDR_001981_20070723225049.DAT
IT_MAPA_KVZ_CDR_000310_20070723225053.DAT
IT_CELL_KVZ_CDR_001982_20070724225507.DAT
IT_MAPA_KVZ_CDR_000311_20070724225511.DAT


it's not good because it's cutting all the "N" and not the exact word "NO"

how can I cut the exact word "NO" ?


Thanks
 
Old 07-25-2007, 08:57 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
In your first code example, you are appending to a file--is that what you intended?

I would use sed. For example, to remove all instances of "NO", do this:

sed 's/NO//g' < oldfile > newfile
 
Old 07-25-2007, 09:15 AM   #3
luzner
LQ Newbie
 
Registered: Jul 2007
Posts: 2

Original Poster
Rep: Reputation: 0
thanks!

It's working thats what i intended

many thanks!
 
  


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
Exact format of quota-file Marc Thoelen Linux - Server 0 07-23-2007 05:42 AM
Exact words verbatim to go in boot menu1st salah-ad-din MEPIS 5 07-10-2006 01:17 PM
Find/locate an exact file stefaandk Linux - General 2 12-27-2005 08:56 AM
how can one know the exact file type using a sys call? mohit_garg Linux - Software 1 11-15-2005 11:01 PM
Search and Replace: Asian Words to English Words ieeestd802 Linux - Software 0 10-27-2004 08:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:59 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration