ksh program that finds the lowest number in a .txt file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh program that finds the lowest number in a .txt file
# 1  
Old 10-24-2011
ksh program that finds the lowest number in a .txt file

i am having a problem finding the lowest number after punching in a bunch of numbers in the .txt file but its probably the way i have the code set up.

help please!
# 2  
Old 10-24-2011
We don't know how your text file looks like... We dont't know how you are punching in the numbers... So show us...

If the text file has the numbers line by line, try this...
Code:
sort input.txt | head -1

--ahamed
# 3  
Old 10-24-2011
in my text file is:
Code:
22
3
5
2
1

# 4  
Old 10-24-2011
Then this should work...
Code:
sort input.txt | head -1

--ahamed
# 5  
Old 10-24-2011
In case of numerical sort, "-n" option must be used.

Code:
$ sort -n ff
1
2
3
5
22
$ sort  ff
1
2
22
3
5
$

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Split a txt file on the basis of line number

I have to split a file containing 100 lines to 5 files say from lines ,1-20 ,21-30 ,31-40 ,51-60 ,61-100 Here is i can do it for 2 file but how to handle it for more than 2 files awk 'NR < 21{ print >> "a"; next } {print >> "b" }' $input_file Please advidse. Thanks (4 Replies)
Discussion started by: abhaydas
4 Replies

2. Shell Programming and Scripting

Sort from highest to lowest number

Hi Guys, I am looking for a way to sort the output below from the "Inuse" count from Highest to Lowest. Is it possible? Thanks in advance. user1 0.12 0.06 0 0.12 User Inuse Pin Pgsp Virtual Unit:... (4 Replies)
Discussion started by: jaapar
4 Replies

3. Shell Programming and Scripting

Ksh: Send a mail in case grep finds something

I want to search a file if it contains special strings and if yes, the records found should be mailed. I can either do it with a temporary file: /usr/bin/grep somestring somefile > /tmp/tempfile && /usr/bin/mail -s "Found something" email@mycomp.com < /tmp/tempfile... or by running the grep... (10 Replies)
Discussion started by: Cochise
10 Replies

4. Shell Programming and Scripting

Perl: find next available lowest number that is available in two arrays

Hi there. I have a number allocation problem whereby I have 2 arrays built from 2 different sources. The arrays will just contain a listed of sorted numbers @a 1 7 10 14 15 16 @b 1 7 10 11 14 15 16 (2 Replies)
Discussion started by: hcclnoodles
2 Replies

5. UNIX for Dummies Questions & Answers

how to generate random number as as the first column of a txt file

Dear all, I have a question. I have a txt file say 4000 rows X 1800 Column. I 'd like to creat a new column as the first column which is a column of random numbers (n=4000) thanks a lot! Lin (2 Replies)
Discussion started by: forevertl
2 Replies

6. Shell Programming and Scripting

KSH script for split a txt file

I have a problem which I would like to solve by using UNIX power and inspired minds around world. Here is the problem I have a text file and it has data as follows 1X.....................1234567890123456789T1234598765XT1 (header) 1Z01............(sub HEADER) P100001............ Q1........... (4 Replies)
Discussion started by: ask.chowhan
4 Replies

7. Shell Programming and Scripting

print every 20 lines the lowest number

Hello all, How can I find the lowest number every 10 lines? For example i have a list name1 -0.1 name2 2 name3 3 name4 -3 name5 1 name6 2 name7 34 name8 34 (6 Replies)
Discussion started by: TheTransporter
6 Replies

8. Shell Programming and Scripting

Korn Shell - Finding lowest number of a file.

I'm writing a KSH script that will get a file on the command line (such as input.txt), and in this file there is on number per line. The program needs to take the file, read each and determine the lowest number in the file. I currently have a while loop setup that will correctly out put every... (8 Replies)
Discussion started by: denyal
8 Replies

9. UNIX for Dummies Questions & Answers

Get the number from the txt file

Hello Guy, I have the following information in the sample.txt, can i get the number and output into sample2.txt - - - - - - - - - - - - - ... (7 Replies)
Discussion started by: happyv
7 Replies

10. AIX

Printing a number of copies of a txt file

Hi, We have an application running on AIX5.3 that generates text files that are sent to be printed using the lp command. The user can specify the number of copies they want printed, but only one copy ever gets printed. I've checked the lp command that is used, and it correctly specifies... (5 Replies)
Discussion started by: stebradshaw
5 Replies
Login or Register to Ask a Question