![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| How can i prepare a file by comparing two other files? | manmohanpv | Shell Programming and Scripting | 3 | 02-18-2008 04:58 AM |
| comparing two numbers with the decimals | chittari | Shell Programming and Scripting | 4 | 06-28-2006 10:57 AM |
| comparing and replacing from one file to another | naren_chella | Shell Programming and Scripting | 3 | 06-07-2006 10:02 AM |
| comparing password file | Bosibus | Shell Programming and Scripting | 7 | 02-16-2005 03:48 PM |
| Comparing two numbers | TabloMaxos | UNIX for Dummies Questions & Answers | 1 | 12-09-2003 10:25 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
comparing numbers in a file
Hello, I'm searching for a quick method to read numeric values from a file or a defined variable and identifying the largest number. For instance if the following numbers are in a file or defined to a variable:
09192007 09202007 09182007 09172007 09162007 What "short" method could be used to id "09202007" as being the largest number read in? Thanks much! |
|
|||||
|
Assuming that the numbers are in a variable, something like this will work:
Code:
a="09192007 09202007 09182007 09172007 09162007" echo $a | tr ' ' '\n' | sort 09162007 09172007 09182007 09192007 09202007 If the numbers are in a file, you can use a similar method: Code:
tr ' ' '\n' < /file/with/numbers | sort 09162007 09172007 09182007 09192007 09202007 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|