Sponsored Content
Full Discussion: find max number
Top Forums Shell Programming and Scripting find max number Post 302285475 by varungupta on Monday 9th of February 2009 03:39:02 AM
Old 02-09-2009
max num. in a file.

Quote:
Originally Posted by moonbaby
Hi, i have a file with numbers in it and i was wondering if there's a script i could use to find the max number and have that printed to a new file?

example a.txt

18
26
47
34
27

so find the max number in a.txt and print it to b.txt.

Thanks!

you can simply use the for loop and get the max no. out of the file: as:

max=1

for in `cat a.txt`
do
if [[ $1 > "$max" ]]; then
max=$1
echo "$max" > b.txt
fi
done

Hope this will work to you.
Thanks
Varun GuptaSmilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Max number of concurrent processes

OS - Sun OS7 What sources can I go to to figure out what is the maximun number of processes for OS7 with 2GB of memory. I believe it is 64K processes, but this number reflects resources being swaped. Any help is appreciated SmartJuniorUnix (1 Reply)
Discussion started by: SmartJuniorUnix
1 Replies

2. Shell Programming and Scripting

Max number of parameters to korn shell?

Hi All, what is the maximum limit for the command line arguments in korn shell. Regards, Raju (4 Replies)
Discussion started by: rajus19
4 Replies

3. Solaris

Max number of Folder in Solaris 8

Hi, Anyone can help ? I have 21,000 sub-folder under the main folder . Now are having some problem writing . Is there a max no. of sub-folder can be create under Solaris . If yes ,what is the max no. , can it be configure to increase ? Thanks (4 Replies)
Discussion started by: civic2005
4 Replies

4. Solaris

Max. Possible number of IOs

Hi, Is there a way to find out the maximum possible number of IOs on a Solaris Servers. I'm using SUN Fire V240 (2 Replies)
Discussion started by: justsam
2 Replies

5. Linux

Max Number of remote X sessions

Hello all, I'm looking to implement a Linux server that will host up to 60 simultaneous X sessions, all running firefox to a secured web interface. Does anyone have any experience sizing a system like this? The reason for the setup isn't as important (Since I really don't understand why... (1 Reply)
Discussion started by: ZekesGarage
1 Replies

6. Shell Programming and Scripting

Find max number in a set

Is there a simple way of calculating the max number in a set of variables, so a=1 b=3 c=6 d=30 something that says e=max($a, $b, $c, $d) I've found a way to do it using: a="1" b="3" c="5" d="50" if ; then t=$a else (3 Replies)
Discussion started by: unclecameron
3 Replies

7. Shell Programming and Scripting

Max number of variables?

Hi Folks.Just out of interest does anyone know if their is a maximum number of variables that korn shell supports and if so how do I query what it is?Cheers (1 Reply)
Discussion started by: steadyonabix
1 Replies

8. Shell Programming and Scripting

Max number of environment variables in Csh

Anyone knows what is the max limit of number of environment variables in Csh? I have a script that when run causes the shell to stop responding to any command like: ls /bin/ls: Argument list too long. And I guess the reason is I passed the max limit for number of environment variables... (1 Reply)
Discussion started by: mohy
1 Replies

9. Solaris

Max. number of NFS mounts

Hi, I was wondering, whether there is a limit regarding the max number of nfs mounts in Oracle Solaris 10 (newest update). The data center plans to migrate from a fibre channel based storage environment (hitachi) to a nfs based storage environment (netapp). Regarding the Solaris 10 database... (1 Reply)
Discussion started by: schms
1 Replies

10. Shell Programming and Scripting

print max number of 2 columns - awk

Is it possible to print max number of 2 columns - awk note: print max if the integer is positive and print min if the integer is negative input a 1 2 b 3 4 c 5 1 d -3 -5 d -5 -3 output a 2 b 4 c 5 d -5 d -5 (4 Replies)
Discussion started by: quincyjones
4 Replies
mlib_VectorMaximumMag_U8C(3MLIB)			    mediaLib Library Functions				  mlib_VectorMaximumMag_U8C(3MLIB)

NAME
mlib_VectorMaximumMag_U8C, mlib_VectorMaximumMag_S8C, mlib_VectorMaximumMag_S16C, mlib_VectorMaximumMag_S32C, mlib_VectorMaximumMag_F32C, mlib_VectorMaximumMag_D64C - find the first element with the maximum magnitude in a vector SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_VectorMaximumMag_U8C(mlib_u8 *max, const mlib_u8 *x, mlib_s32 n); mlib_status mlib_VectorMaximumMag_S8C(mlib_s8 *max, const mlib_s8 *x, mlib_s32 n); mlib_status mlib_VectorMaximumMag_S16C(mlib_s16 *max, const mlib_s16 *x, mlib_s32 n); mlib_status mlib_VectorMaximumMag_S32C(mlib_s32 *max, const mlib_s32 *x, mlib_s32 n); mlib_status mlib_VectorMaximumMag_F32C(mlib_f32 *max, const mlib_f32 *x, mlib_s32 n); mlib_status mlib_VectorMaximumMag_D64C(mlib_d64 *max, const mlib_d64 *x, mlib_s32 n); DESCRIPTION
Each of these functions finds the first element with the maximum magnitude in a complex vector, then puts the real and imaginary parts of it into max[0] and max[1], respectively. PARAMETERS
Each of the functions takes the following arguments: max Pointer to the first element with the maximum magnitude. x Pointer to the first element of the source vector. n Number of elements in the source vector. RETURN VALUES
Each of the functions returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mlib_VectorMinimumMag_U8C(3MLIB), mlib_MatrixMaximumMag_U8C(3MLIB), mlib_MatrixMinimumMag_U8C(3MLIB), attributes(5) SunOS 5.10 9 Nov 2004 mlib_VectorMaximumMag_U8C(3MLIB)
All times are GMT -4. The time now is 08:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy