The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using cp -r command to selectively omit *.dat files while copying a directory. d_sai_kumar UNIX for Dummies Questions & Answers 5 07-18-2008 07:48 AM
need assistance: sed and repeating patterns metalwarrior UNIX for Advanced & Expert Users 1 02-02-2008 05:00 AM
Loop through files in dir, omit file with latest date stringzz Shell Programming and Scripting 2 12-04-2007 02:04 PM
merge 2 files (without repeating any lines) bluemoon1 Shell Programming and Scripting 9 10-25-2007 11:31 PM
Repeating commands in a script Dave2874 Shell Programming and Scripting 4 03-14-2005 10:34 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-22-2005
TheCrunge TheCrunge is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 30
Omit repeating lines

Can someone help me with the following 2 objectives?

1) The following command is just an example. It gets a list of all print jobs. From there I am trying to extract the printer name. It works with the following command:


Code:
lpstat -W "completed" -o | awk -F- '{ print $1}'

Problem is, I want to be able to omit these multiple lines:


Code:
My_office_printer
My_office_printer
My_office_printer
My_home_printer
My_home_printer

So it looks like this:


Code:
My_office_printer
My_home_printer

Now, each line is actually different (because each one is its own print job), but because I use awk to just get the name of the printer, the end result displays the printer name for however many print jobs there were. I just want one instance of each printer name.


2) In the previous section, I want to reduce the number of lines returned to one per printer. Before I do, I want to count how many there are. For example, how many time was My_office_printer listed.

Any help is greatly appreciated....
 

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:55 PM.


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