I have a script that puts a list of files in two separate arrays:
First, I get a file list from a ZIP file and fill `FIRST_Array()` with it. Second, I get a file list from a control file within a ZIP file and fill `SECOND_Array()` with it
Third, I compare both array like so:
I can tell that `Diff` fails because I output each array to files: `FIRST.report.out` and `SECOND.report.out` are simply not sorted properly.
1) FIRST.report.out (what's inside the ZIP file)
2) SECOND.report.out (what's inside the ZIP's control file)
Using sort -k12 -t~ made sense since ~ is the delimiter for the file's date field ("20120808" : 12th position). But it is not working consistently.
The sort is worse when my script processes bigger ZIP files. Why is sort -k not working all the time? How can I sort both arrays?
What shell are you using? I'm not familiar with a redirection operator of the form:
Sorry. Never mind. It is a bash feature. This form is not available in ksh and is an extension to the POSIX shell.
Last edited by Don Cragun; 08-08-2012 at 09:39 PM..
What shell are you using? I'm not familiar with a redirection operator of the form:
Sorry. Never mind. It is a bash feature. This form is not available in ksh and is an extension to the POSIX shell.
ksh88 and ksh93 both support that construct. The process substitution, <(cmd ...) is replaced with /dev/fd/n, and the first < is the usual input redirection operator.
ksh88 and ksh93 both support that construct. The process substitution, <(cmd ...) is replaced with /dev/fd/n, and the first < is the usual input redirection operator.
Regards,
Alister
That's interesting. The ksh on Mac OS X Lion (Version M 1993-12-28 s+ $) says:
Quote:
-ksh: syntax error: `<(' unexpected
when given the command:
The New Kornshell Command and Programming Language book by Nolsky and Korn does say that Process Substitution using this form is a "Possible Extension" that
Quote:
is available only on versions of the UNIX system that support the /dev/fd directory for naming open files.
and OS X does support /dev/fd. It looks like someone at Apple failed to configure OS X's ksh to give us access to this feature.
Hi Guru,
I need some help regarding awking the output so it only show the first line (based on column) of each row.
So If column has 1, three row, then it only show the first line of that row, based on similar character in column 1. So i am trying to achieve a sort, based on column one and... (3 Replies)
Input file:
100%ABC2 3.44E-12 USA
A2M%H02579 0E0 UK
100%ABC2 5.34E-8 UK
100%ABC2 3.25E-12 USA
A2M%H02579 5E-45 UK
Output file:
100%ABC2 3.44E-12 USA
100%ABC2 3.25E-12 USA
100%ABC2 5.34E-8 UK
A2M%H02579 0E0 UK
A2M%H02579 5E-45 UK
Code try:
sort -k1,1 -g -k2 -r input.txt... (2 Replies)
How do you combine these ls commands so that I can have the outputs by name, time stamp, and size?
ls -al |grep name_of_file
ls -al | sort +4nr
ls -l -t
Please advise. (4 Replies)
Hello all,
I have a file - 12.txt
cat 12.txt
===============================================
Number of executions = 2 Total execution time (sec.ms) = 0.009883
Number of executions = 8 Total execution time (sec.ms) = 0.001270
Number of... (23 Replies)
Hi ,
I would like to list or sort by date and time (the files are named in day and time format) where the latest file will be placed at the bottom and the earliest file be placed at the top. Can anybody help me?
My files are named in the following manner.
EG: abc_071128_144121_data
"... (21 Replies)