Finding the right file with multiple sort criteria
Hello,
I have files in a directory with names like,
I need to find the smallest value for the first '_' delimited field (84.40 in this case). Where there are more than one file with this value, like above, I need the one with the smallest value of the int in 1300-ON-0.25, 1200-ON-0.25, etc. For this example, I would want to find the file and assign that name to a bash variable.
There will never be more than 2 files with the same value for the field I am looking at.
Another caveat is that there are times where I would be looking at the float in the third '_' delimited field instead of the first. If $STOP_ON==T, I would sort on the third number and if $STOP_ON=V I would sort on the first.
I guess what I would do here is something like,
This would strip off the path, sort on the float that I need and then pick off the top two. I could then process the list to find the one with the lowest value for the second sorting criteria.
This seems rather involved and there is another problem in that there may not be two files with the same value for the first sort filed as there are in this example. That means I would first have to check the results of the above code for that as well.
It seems as if there should be a better way to do this. Please let me know if I have botched my explanation and want me to try again.
I thought that when you did something like FILES=$(ls ...) you would end up with an array if there was more than one file returned by ls. For some reason, it is treating the list of files as a single string in one element. I tried adding {OFS=" "} to the awk call, but that doesn't do anything.
For now, I can split up the single string in ${FILES[0]} on space, but it seems like I shouldn't have to do that.
I am running a command that is part of a script and this is what I am getting when it is sorted by the command:
command:
ls /tmp/test/*NDMP*.z
/tmp/test/CARS-GOLD-NET_CHROMJOB-01-XZ-ARCHIVE-NDMP.z
/tmp/test/CARS-GOLD-NET_CHROMJOB-01-XZ-NDMP.z... (2 Replies)
I am new to UNIX Shell. I want to list the files names in the current directory that are not start with 'AB' and have at least two characters. For example, say I have those files in the current directory: AB, AC, AD, AE, B, C. After executing the command, AC, AD, AE will be listed on the screen. ... (6 Replies)
Hi all,
i have a text file like the below example---
146 7600 147 23996
43024 50700581 28998 1767165
10 3784 12 1344
0 0 0 545
641 166646 723 90136
24 1046 46 2948
OR
4340 ... (15 Replies)
Hi,
I have a fixed length file where I need to verify the values of 3 different fields, where each field will have a different value.
How can I do that in a single step. (6 Replies)
Hello,
I"m a newbie :). I hope I can learn from the scripting expert.
I'm trying to use egrep and grep commands to get the total count by meeting both criteria. So far, I haven't been able to do it.
if robot = TLD and barcode = AA, then final count should be 2
if robot = TLD and... (9 Replies)
Hi all,
I am newbie in unix. Just have some doubts on how to join multiple lines into single line.
I have 1 file with following contents.
R96087641
HostName-kul480My
This is no use any more
%%
E78343970
LocalPath-/app/usr/SG
(Blank in this line)
%%
E73615740... (4 Replies)
I have a list of people in a usage log and need to print the names and phone numbers of people with over 500 logins. I'd also like to display these names alphabetically.
I have their total logins set to a variable named total.
So far, I have very little in my awk script to do this:
FS=":"... (4 Replies)
Hi,
I would like to know given that I have 3 columns.
Let say I have first 3 columns to do operation and these operation output is printed out each line by line using AWK and associative array.Currently in the output file, I do a sort by -r for the operation output.
The problem comes to... (1 Reply)
I would like a simple shell script that will allow me to display to screen all unsuccessful su attempts in my sulog file, for the present date.
I have been trying several different combinations of commands, but I can't quite get the syntax correct.
The mess I have right now (don't laugh) is... (4 Replies)
i was just wondering if any one had a good example of finding mutliple file types with the -o option or any other alternatives.
find . \( -name "*.txt" -o -name "*.tag" \)
for some reason i'm not having much luck and the man page isn't very descriptive.
what i am trying to do is find all... (6 Replies)