Sponsored Content
Top Forums Shell Programming and Scripting Avoiding For Loop in Shell Script Post 302548596 by Chubler_XL on Thursday 18th of August 2011 09:24:10 PM
Old 08-18-2011
Is this what you were after:

Code:
awk '
   { for(i=1;i<=NF;i++) {
      max=$i>max?$i:max;
      if(!(++cnt%3)) {
          print max;
          max=-999;
   }}}
   END { if(cnt%3) print max }' file

@Corona688 - One word per phone call - Nice analogy, I'll file that one away for later use

Last edited by Chubler_XL; 08-18-2011 at 10:31 PM..
This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If then else loop in Shell script

Hi Following is the code . When I give input as Bangalore,its dospalying Welcome to Hitech City. But say , if I select Delhi or US, its not displaying the corresponding message. Its still says Welcome to Hitech City. Seems that it not entering in the elif part. Please suggest. #!... (4 Replies)
Discussion started by: pankajkrmishra
4 Replies

2. Shell Programming and Scripting

Problem with while loop in shell script

Hi All, How to read a file upto last line(End Of Line) I wrote below program: cat R2_20060719.610.txt | while read LINE do echo "$LINE" done above code reading all lines from a file and skipping last line...... is there anything wrong in my code. Please help me out from this... (20 Replies)
Discussion started by: rkrgarlapati
20 Replies

3. Shell Programming and Scripting

Help with loop in a shell script

I just want to write a little script, that reads the lines from a file, echos somthing in a new tmp.file and then do some commands whith the tmp.files. while read -r line do echo "TEST=" > tmp.$$ echo "$line" >> tmp.$$ any_command < tmp.$$ done < $INPUTFILE But I think I have to... (2 Replies)
Discussion started by: elifchen
2 Replies

4. Shell Programming and Scripting

Loop in shell script

Dear experts, i am quite new to shell script please any one can help me in this regard i would like write a script which takes input in the form >./Test.sh a,10,b,20,c,30... in this way i can give input in any number which is not constant in the end through loop i want to... (3 Replies)
Discussion started by: vin_pll
3 Replies

5. Shell Programming and Scripting

Shell script using loop

Hi everyone, I have n number of data in my file "temp" in following order.In each line table_name and column_name are different.input data is in same format each query in three lines. ALTER TABLE table_name ADD ( column_name1 VARCHAR2(10), column_name2 VARCHAR2(70) ); ... (23 Replies)
Discussion started by: alisha
23 Replies

6. Shell Programming and Scripting

Help with IF statement with loop Shell Script

Hello I am very new to shell and I bought some books and trying to learn it. I started trying to write a script that will take a number and count it down to 1 with commas in between. This number can only be one argument. If lower than one or higher than one argument it sends an error message. ... (4 Replies)
Discussion started by: zero3ree
4 Replies

7. UNIX for Dummies Questions & Answers

Avoiding the second run of the script

Hi all, I want to put a check in my script to check if the same instance is already running and not finished and if not then does not allow it to run! in which part of my script I should put this? and any idea how I should write it? tx (4 Replies)
Discussion started by: messi777
4 Replies

8. Shell Programming and Scripting

Help with the For loop shell script

Hi, I have multiple files in a directory. Each file will have a header.I have to check if any of the files has 0 rows other than the header then I have to delete the files. Here “ Empty file” in my case means a file has header information but no data. I have to delete such files. If the file... (2 Replies)
Discussion started by: ganesnar
2 Replies

9. Shell Programming and Scripting

Avoiding some files inside a loop

In my script I need to loop around some files like below example files are fa.info.abcd fa.info.bxde fa.info.cdas ------ for test_data in fa.info.* do # Some text appending logic applied # Copy to another directory done Now I need to discard some files while looping around ... (9 Replies)
Discussion started by: smile689
9 Replies

10. Shell Programming and Scripting

Loop in shell script

Hi Friends, I have a file. the content is as below: file1: /A/B/C/abc.txt 2013-07-28 13:50:00,2013-07-31 01:00:00,5,710 /A/B/C/xyz.txt 2011-09-21 18:30:00,2013-07-30 06:15:00,15,65135 2009-11-09 18:00:00,2011-09-02 09:00:00,5,12345 2013-07-28 13:50:00,2013-07-31 01:00:00,5,710 ... (2 Replies)
Discussion started by: vsachan
2 Replies
ns_rand(3aolserver)					    AOLserver Built-In Commands 				       ns_rand(3aolserver)

__________________________________________________________________________________________________________________________________________________

NAME
ns_rand - commands SYNOPSIS
ns_rand ?max? _________________________________________________________________ DESCRIPTION
ns_rand generates a cryptographically-secure random number. If max is not specified, the random number is a floating-point value n such that 0.0 <= n < 1.0. If max is specified, it must be a positive integer between 0 and 2147483647. The return value is an integer value such that 0 <= n <= (max - 1). Internally ns_rand is implemented with the drand48(3) and lrand48(3) standard library functions. An internal random seed is generated the first time ns_rand is called after the server starts. EXAMPLES
nscp> ns_rand 0.39938485692 nscp> ns_rand 10 7 SEE ALSO
nsd(1), info(n), drand48(3), lrand48(3) KEYWORDS
AOLserver 4.0 ns_rand(3aolserver)
All times are GMT -4. The time now is 11:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy