I have and input file like this:
I'm interested in second field, for example the second element of second field is "240x151+140+624". If we use as field separator "+" for this second field, then would be 3 subfields within original 2nd field.
I want to have and awk array (in this case array "a") with this 2nd field sorted first by 3rd subfield and then by second subfield (where new FS="+").
I'm doing this and it works with the code below but I need first an awk program, then pipe to sort command then pipe again for the 2nd awk program.
How to get the sorted array "a" in a single awk program (without pipe twice) to be able to make further processing in the END{} block?
With close to 300 posts, you should know that supplying OS, shell, and tools' names and versions helps peopls help you. You usage of length(a) for array a seems to indicate gawk which offers greatly different possibilities, e.g. the sort function, than e.g. my mawk, for which a pipe through sort would be indispensable.
Your second pipe into the second awk is pointless, as you collect the stdin into an array, and then, in the END section, just print the array in sequence. Just drop it.
You may even drop the sort command that you pipe into, if you make use of gawk's sorting capabilities. If you can't, you could run the sort command from within awk, like
, but the effect will be marginal, compared to the external piping.
For what reason do you skip line 2 of the input file?
I'm using bash in Cygwin under Windows. I have access to awk and gawk.
The input file shows coordinates and sizes of some regions within an image. I skip the first coordinate because it represents the entire image itself and I don't need that.
I cannot drop the second awk program because I want to have the sorted coordinates in an array because finally I need to print them in especific order. For example, once having the coordinates sorted within an array I need to print from element 2 to 5, then print element 1, then print from 6th to N-1 and then print last element of array.
I hope make sense why I need to have the sorted info in an array.
Hi ,
In a directory list of ddl files are stored in the given format above. Above is the sample ddl file. The ddl file name is same as that of table name ie email_notifications.ddl
I want to generate below report using awk utility reading all the ddl files stored in /ddl path
Desired output:... (1 Reply)
Hello All,
Can you please help me with the below.
#!/bin/bash
ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5 EXTRACT_DT:30-SEP-12 VER_NUM:1"
ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5... (14 Replies)
Hello,
I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this :
This is the output of ls command : I stored the output in a file filelist
1.1M... (5 Replies)
Hi folks,
Sorry for something I'm sure was answered already, I just could not find it in a search of the forums.
I am trying to build a script that eats a config file as:
cat file.cnf | ConProcess.shWhat I want to do inside the script is:
!#/usr/bin/bash
# captured piped cat into an... (6 Replies)
hi guys,
I am writing a c program that generates a two dimensional array to make matrix and a vector of random numbers and perform multiplication. I can't figure out whats wrong with my code. It generates a matrix of random numbers but all the numbers in the vector array is same and so is the... (2 Replies)
Dear All,
I am trying to sort an array of numbers to retrieve the mimimum and maximum values of numbers in that array, by printing the first and last elements of the sorted array. My code is @sorted_numbers = sort (@numbers);
print "@sorted_numbers\n";
print "$sorted_numbers,... (0 Replies)
Hello,
I have the line underneath generated by lssyscfg command:
"""51/client/1/pcyaz0hjfv00-vio1/651/c050760107fd0466,c050760107fd0467/1"",""52/client/2/pcyaz0hjfv01-vio2/652/c050760107fd0468,c050760107fd0469/1"",""31/client/1/pcyaz0hjfv00-vio1/375/c050760107fd046a,c050760107fd046b/1"""... (1 Reply)
Hi,
I am trying to define number of array based on constant derived during execution phase of a script. Here is what i am trying..
#First Part, Get LUN input from User
lun_count=4
count=0
set -A my_lun
while :
do
while ]; do
read L?"Enter Lun "$count" Number:"
... (2 Replies)
Hi,
i have to make a command in unix system which make a sorted list by cpu time (not %cpu ). If the application exists more than a time I would like to keep only one copy.
Could you help me please ???
P.s : I am trying --> ps aux --sort -%cpu | uniq
but I understand that is wrong (5 Replies)