Sponsored Content
Top Forums Shell Programming and Scripting Sort files by date in filename Post 302585148 by Yuggy on Tuesday 27th of December 2011 05:11:32 PM
Old 12-27-2011
So basically, you mean that even if I have for example the following files:

Code:
IGL01_AC_D_20110615_N01_01.dat
IGL01_AC_D_20110614_N02_01.dat
IGL01_AC_D_20110614_N01_01.dat
IGL01_AC_D_20110614_N01_02.dat

Code:
ls IGL01*.dat | sort -t_ -k4

will give the following result?

Code:
IGL01_AC_D_20110614_N01_01.dat
IGL01_AC_D_20110614_N01_02.dat
IGL01_AC_D_20110614_N02_01.dat
IGL01_AC_D_20110615_N01_01.dat

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Renaming files to have date/time in filename

I have a program that will export my data to a single file, but it assigns a file name that is overridden every time I run the program. I need to change the file name to have a sequential number in the filename. How do I rename a file so that the filename contains the system date and time. I want... (5 Replies)
Discussion started by: wayneb
5 Replies

2. Shell Programming and Scripting

Sort files by Date-timestamps available in filename & pick the sortedfiles one by one

Hi, I am new to Unix shell scripting. Can you please help me with this immediate requirement to code.. The requirement is as given below. In a directory say Y, I have files like this. PP_100000_28062006_122731_746.dat PP_100000_28062006_122731_745.dat PP_100000_28062006_122734_745.dat... (4 Replies)
Discussion started by: Chindhu
4 Replies

3. Linux

sort files by date

Hi All, Sorry to throw this frequent question but I lost my notes on it. How do you list the files by date? I'm on red hat. Thanks in advance, itik (1 Reply)
Discussion started by: itik
1 Replies

4. UNIX for Dummies Questions & Answers

Sort files by date, not showing files from today

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)
Discussion started by: carlosdivega
3 Replies

5. Shell Programming and Scripting

Move files based on date in filename

I know this gets covered quite a bit in the forum and I think there is enough there for me to figure out how to do what I am trying to do, I just don't think I would do it very efficiently so I am going to ask the question... I have database log files with date and time stamps in the file like ... (7 Replies)
Discussion started by: slatoms
7 Replies

6. UNIX for Dummies Questions & Answers

sort files by numeric filename

dear all, i have .dat files named as: 34.dat 2.dat 16.dat 107.dat i would like to sort them by their filenames as: 2.dat 16.dat 34.dat 107.dat i have tried numerous combinations of sort and ls command (in vain) to obtain : 107.dat 16.dat 2.dat 34.dat (1 Reply)
Discussion started by: chen.xiao.po
1 Replies

7. Shell Programming and Scripting

URGENT!!! bash script to sort files into folder according to a string in the filename

Hi all. I am very new to linux scripting and i have a task i can only solve with a script. I need to sort files base on the date string in their filenames and create a folder using the same date string then move the files to their respective folders. Scenario: Folder Path:... (1 Reply)
Discussion started by: ace47
1 Replies

8. Shell Programming and Scripting

Bash script to sort files into folder according to a string in the filename

Hi all. I am very new to linux scripting and i have a task i can only solve with a script. I need to sort files base on the date string in their filenames and create a folder using the same date string then move the files to their respective folders. Scenario: Folder Path:... (1 Reply)
Discussion started by: ace47
1 Replies

9. Shell Programming and Scripting

Find files greater than a particular date in filename.

I need a unix command which will find all the files greater that a particular date in the file name. say for example I have files like(filenaming cov : filename.YYDDMMSSSS.txt) abc.201206015423.txt abc.201207013456.txt abc.201202011234.txt abc.201201024321.txt efg.201202011234.txt... (11 Replies)
Discussion started by: lijjumathew
11 Replies

10. Shell Programming and Scripting

Sort log files based on numeric value in the filename

Hi, I have a list of log files as follows: name_date_0001_ID0.log name_date_0001_ID2.log name_date_0001_ID1.log name_date_0002_ID2.log name_date_0004_ID0.log name_date_0005_ID0.log name_date_0021_ID0.log name_date_0025_ID0.log .......................................... (4 Replies)
Discussion started by: alex2005
4 Replies
hpls(1) 						      General Commands Manual							   hpls(1)

NAME
hpls -- list the contents of a directory on an HFS+ volume SYNOPSIS
hpls [options] [hfs-path ...] Description hpls is used to list files and directories on an HFS+ volume. If one or more arguments are given, each file or directory is shown; other- wise, the contents of the current working directory are displayed. Options -1 Each entry appears on a line by itself. This is the default if standard output is not a terminal. -a All entries are shown, including "invisible" files. The default is to omit invisible files. -c Sort and display entries by their creation date, rather than their modification date. -d List directory entries themselves rather than their contents. Normally the contents are shown for named directories on the com- mand-line. -i Show the catalogue ID for each entry. Every file and directory on an HFS+ volume has a unique catalogue ID. -l Display entries in long format. This format shows the entry type ("d" for directory, "f" for file, "F" for locked file), flags ("i" for invisible), type and creator (four-character strings) for files only, size (number of items in a directory or resource and data bytes of a file, respectively), date of last modification (or creation if the -c flag is given), and name. -m Display entries in a continuous format separated by commas. -q Replace special and non-printable characters in displayed filenames with question marks (?). This is the default when standard output is a terminal. -r Sort entries in reverse order before displaying. -s Show the file size for each entry in 1K block units. The size includes blocks used for both data and resource forks. -t Sort and display entries by time. Normally files will be sorted by name. This option uses the last modification date to sort unless -c is also specified. -x Display entries in column format like -C, but sorted horizontally into rows rather than columns. -w width Format output lines suitable for display in the given width. Normally the width will be determined from your terminal, from the environment variable COLUMNS, or from a default value of 80. -C Display entries in column format with entries sorted vertically. This is the default output format when standard output is a terminal. -F Cause certain output filenames to be followed by a single-character flag indicating the nature of the entry; directories are fol- lowed by a slash "/" and executable Macintosh applications are followed by an asterisk "*". -N Cause all filenames to be output verbatim without question-mark substitution. -R For each directory that is encountered in a listing, recursively descend into and display its contents. See also hfsplus(7), hpmount(1), hpcd(1), hppwd(1), hprm(1), hpmkdir(1), hpcopy(1), hpumount(1), hpfsck(1). Author This manual page was written by Jens Schmalzing <jensen@debian.org> for Debian GNU/Linux using the manual page by Klaus Halfmann <half- mann@libra.de> that comes with the source code and documentation from the Tech Info Library. hpls(1)
All times are GMT -4. The time now is 04:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy