Re: Sort files by filename



Mark Haney wrote:

With apologies to the 2 Les', the situation isn't like that and I
apologize if I've not been clear. The application that I'm working with
is running on a server that simply relays the data to all our
customers, it doesn't store a copy of the files and then feed them. The
NWS weather data requires as close to real-time performance and the
'series of tubes' allows. That said, I'm running another server that
runs the same application but is designed to pull the data feed and then
store the files locally. I /can/ store the files on the primary server,
and I have, but this is a production server that feeds 13MB/hr for each
of the 60 or so radar sites it handles 24/7 so I don't like asking it to
do more than it does.

So, in essence I'm stuck with these files being dumped on a server via a
proprietary method. So I need to sort the files and check for missing
ones on the filesystem.

The early suggestions were great and I'm trying each one and tweaking to
see if I can make them work with what I have. But any additional bash
tips would be helpful as I am pressed for an answer to this issue.

If your data has a fixed file length, cut can separate out the
specific bytes you want to sort on. If not, then if there is a
specific separator between parts of the name, bot cut and sort can
use that to grab the part you want to sort on. What I suspect would
work well on for you is to feed the output of ls though sort, and
then use a for loop with counter to compare the part you are
interested in to check for missing numbers. By doing a compare of
the first part of the file name, you can reset the counter for each
series of files. Or you can have ls only produce one set of files.

count=xx
for i in $(ls <something>* | sort) ; do
file_num=$(cut --delimiter=_ -f1 $i)
while [ $count -lt $file_num ] ; do
echo Missing file number $count
count++
done
done


This is a very rough script to give you an idea. I can see problems
where you get a file name that is in the wrong format, that causes
the while loop to go on forever. But if I didn't make too many
syntax errors, it should give you a starting point.

Mikkel
--

Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

Attachment: signature.asc
Description: OpenPGP digital signature

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list

Relevant Pages

  • Re: Sort files by filename
    ... is running on a server that simply relays the data to all our ... it doesn't store a copy of the files and then feed them. ... but this is a production server that feeds 13MB/hr for each ... So I need to sort the files and check for missing ...
    (Fedora)
  • Re: Putting a telly where an aerial feed wont go
    ... aerial entry point (via some sort of amplifier/splitter). ... the rear wall, over the roof and down the front of the house. ... degraded by trying to split it into two feeds. ... in a bit more cable and what sort of splitter I should use gratefully ...
    (uk.tech.digital-tv)
  • Re: Sort files by filename
    ... is running on a server that simply relays the data to all our ... but this is a production server that feeds 13MB/hr for each ... Otherwise routing delays could cause you additional ... list of missing files, and it would take only milliseconds, primarily ...
    (Fedora)
  • Re: Putting a telly where an aerial feed wont go
    ... aerial entry point (via some sort of amplifier/splitter). ... rear wall, over the roof and down the front of the house. ... trying to split it into two feeds. ... possible (I'm a tad over 60 and don't install TV aerials for a ...
    (uk.tech.digital-tv)
  • Re: OE6 says no new messages, but there ARE
    ... Then retry the View, Sort by. ... The server name is on the servers tab in the box labelled: ... It's like they download into a ... >> Troubleshooting Logging for Mail and verify that you see RETR requests. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)