Do you mean that you want the seconds displayed in the listing? Using ls -lt will sort by seconds, but they won't display by default.
If you need to know the value of seconds, you would be better using the stat command for each file and extracting the part you want, e.g. stat -t /tmp/unix/* | sort -nk 13
This assumes that there are no spaces in the files/paths but might help. The thirteenth column is the file modification time (i.e. edit of the file content) which I'm guessing you might want more than other details. The value is in seconds from Epoch (1970-01-01 00:00:00) but you can use stat options to force the output into a format suitable for you.
I hope that this helps. If I've got it all wrong, please describe what you need.
Hi everyone,
I have some large text files that I need to split into a specific number of files of equal size. As far as I know (and I don't really know that much :)) the split command only lets you specify the number of lines or bytes. The files are all of a different size, so the number of... (4 Replies)
Hi all,
i'm new here in this forum. I really like the helpful answers in this forum.
Here a short question.
For a script i have to sort files by date and exclude the files of the actual date.
Sorting the files by date and preparing the output for awk is done by this line:
ls -l... (3 Replies)
Hi,
I am new to scripting. I need a script to sort and the records in a file and then split them into different files.
For example, the file is:
H1......................
H2......................
D2....................
D2....................
H1........................... (15 Replies)
Dear All,
I am a newbie to shell scripting so this one is really over my head.
I have a text file with five fields as below:
76576.867188 6232.454102 2.008904 55.000000 3
76576.867188 6232.454102 3.607231 55.000000 4
76576.867188 6232.454102 1.555146 65.000000 3
76576.867188 6232.454102... (19 Replies)
Hello all -
I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Hi, this is about sorting a very large file (like 10 gb) to keep lines with unique entries across SOME of the columns.
The line originally looked like this:
sort -u -k2,2 -k3,3n -k4,4n -k5,5n -k6,6n file_unsorted > file_sorted
please note the -u flag.
The problem is that this single... (4 Replies)
Hi
I have a requirement like below
I need to sort the files based on the timestamp in the file name and run them in sorted order and then archive all the files which are one day old to temp directory
My files looks like this
PGABOLTXML1D_201108121235.xml... (1 Reply)
Hi,
I am using SUN SOLARIS (SunOS sun4v sparc SUNW, T5240).
I have a huge data file with header and trailer. This file gets used into an ETL process. ETL skips the header record (which is the first record of the file) and loads the rest of the record. The file can be delimited (comma,... (5 Replies)
Hello,
I need to split a file by number of records and rename each split file with actual filename pre-pended with 3 digit split number.
What I have tried is the below command with 2 digit numeric value
split -l 3 -d abc.txt F (# Will Produce split Files as F00 F01 F02)
How to produce... (19 Replies)
i use the split command to split a one terabyte backup file into 10 chunks of 100 GB each. The files are split one after the other. While the files is being split, I will like to scp the files one after the other as soon as the previous one completes, from server A to Server B. Then on server B ,... (2 Replies)
Discussion started by: malaika
2 Replies
LEARN ABOUT OSX
file::listing
File::Listing(3) User Contributed Perl Documentation File::Listing(3)NAME
File::Listing - parse directory listing
SYNOPSIS
use File::Listing qw(parse_dir);
$ENV{LANG} = "C"; # dates in non-English locales not supported
for (parse_dir(`ls -l`)) {
($name, $type, $size, $mtime, $mode) = @$_;
next if $type ne 'f'; # plain file
#...
}
# directory listing can also be read from a file
open(LISTING, "zcat ls-lR.gz|");
$dir = parse_dir(*LISTING, '+0000');
DESCRIPTION
This module exports a single function called parse_dir(), which can be used to parse directory listings.
The first parameter to parse_dir() is the directory listing to parse. It can be a scalar, a reference to an array of directory lines or a
glob representing a filehandle to read the directory listing from.
The second parameter is the time zone to use when parsing time stamps in the listing. If this value is undefined, then the local time zone
is assumed.
The third parameter is the type of listing to assume. Currently supported formats are 'unix', 'apache' and 'dosftp'. The default value is
'unix'. Ideally, the listing type should be determined automatically.
The fourth parameter specifies how unparseable lines should be treated. Values can be 'ignore', 'warn' or a code reference. Warn means
that the perl warn() function will be called. If a code reference is passed, then this routine will be called and the return value from it
will be incorporated in the listing. The default is 'ignore'.
Only the first parameter is mandatory.
The return value from parse_dir() is a list of directory entries. In a scalar context the return value is a reference to the list. The
directory entries are represented by an array consisting of [ $filename, $filetype, $filesize, $filetime, $filemode ]. The $filetype value
is one of the letters 'f', 'd', 'l' or '?'. The $filetime value is the seconds since Jan 1, 1970. The $filemode is a bitmask like the
mode returned by stat().
COPYRIGHT
Copyright 1996-2010, Gisle Aas
Based on lsparse.pl (from Lee McLoughlin's ftp mirror package) and Net::FTP's parse_dir (Graham Barr).
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.16.2 2012-02-15 File::Listing(3)