Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-25-2007, 07:38 AM   #1
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's not good because it's cutting all the "N" and not the exact word "NO"

how can I cut the exact word "NO" ?

Old 07-25-2007, 07:57 AM   #2
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, 08:15 AM   #3
LQ Newbie
Registered: Jul 2007
Posts: 2

Original Poster
Rep: Reputation: 0

It's working thats what i intended

many thanks!


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

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

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