Sponsored Content
Top Forums UNIX for Dummies Questions & Answers sort file on timestamp and a alphabetic code in it Post 302242969 by joeyg on Friday 3rd of October 2008 09:35:51 AM
Old 10-03-2008
Without recreating your filestructure, I copied the output of your ls -ltr to file9a
Code:
> cat file9a
-rwx------ 1 dsadm dstage 81 Oct 03 10:53 ER08EVENTAA080910224550.txt
-rwx------ 1 dsadm dstage 81 Oct 03 10:56 ER08EVENTAA080910232010.txt
-rwx------ 1 dsadm dstage 81 Oct 03 11:38 ER08EVENTAA080910130150.txt
-rwx------ 1 dsadm dstage 81 Oct 03 11:47 ER08EVENTAA080911015005.txt
-rwx------ 1 dsadm dstage 81 Oct 03 11:51 ER08EVENTAA080910232000.txt
-rwx------ 1 dsadm dstage 81 Oct 03 12:06 ER08EVENTAA080910130245.txt
-rwx------ 1 dsadm dstage 81 Oct 03 12:22 ER08EVENTCD080910130245.txt
-rwx------ 1 dsadm dstage 81 Oct 03 12:23 ER08EVENTCD080910222222.txt
-rwx------ 1 dsadm dstage 81 Oct 03 12:34 ER08EVENTCD080911232323.txt
-rwx------ 1 dsadm dstage 81 Oct 03 12:35 ER08EVENTDC080911232324.txt

Code:
> cut -d" " -f9 file9a
ER08EVENTAA080910224550.txt
ER08EVENTAA080910232010.txt
ER08EVENTAA080910130150.txt
ER08EVENTAA080911015005.txt
ER08EVENTAA080910232000.txt
ER08EVENTAA080910130245.txt
ER08EVENTCD080910130245.txt
ER08EVENTCD080910222222.txt
ER08EVENTCD080911232323.txt
ER08EVENTDC080911232324.txt

Which leave two choice. Cut out the 9th field from the data stream and then sort...
Code:
> cut -d" " -f9 file9a | sort -k1.10,23
ER08EVENTAA080910130150.txt
ER08EVENTAA080910130245.txt
ER08EVENTAA080910224550.txt
ER08EVENTAA080910232000.txt
ER08EVENTAA080910232010.txt
ER08EVENTAA080911015005.txt
ER08EVENTCD080910130245.txt
ER08EVENTCD080910222222.txt
ER08EVENTCD080911232323.txt
ER08EVENTDC080911232324.txt

Or, sort on the 9th field
Code:
> sort -k9.10,23 file9a
-rwx------ 1 dsadm dstage 81 Oct 03 11:38 ER08EVENTAA080910130150.txt
-rwx------ 1 dsadm dstage 81 Oct 03 12:06 ER08EVENTAA080910130245.txt
-rwx------ 1 dsadm dstage 81 Oct 03 10:53 ER08EVENTAA080910224550.txt
-rwx------ 1 dsadm dstage 81 Oct 03 11:51 ER08EVENTAA080910232000.txt
-rwx------ 1 dsadm dstage 81 Oct 03 10:56 ER08EVENTAA080910232010.txt
-rwx------ 1 dsadm dstage 81 Oct 03 11:47 ER08EVENTAA080911015005.txt
-rwx------ 1 dsadm dstage 81 Oct 03 12:22 ER08EVENTCD080910130245.txt
-rwx------ 1 dsadm dstage 81 Oct 03 12:23 ER08EVENTCD080910222222.txt
-rwx------ 1 dsadm dstage 81 Oct 03 12:34 ER08EVENTCD080911232323.txt
-rwx------ 1 dsadm dstage 81 Oct 03 12:35 ER08EVENTDC080911232324.txt

My previous example sorted on field 1, similar to the command you showed in your earlier example. (I assumed you cut to the 9th field so that you would sort on the field #1.)
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sort for timestamp information-YYYY-MM-DD HH:MM:SS

Dear all, Please advice how do I sort a file based on timestamp information. I want to sort the second column in asc/desc order which has timestamp information in format YYYY-MM-DD HH:MM:SS Example File - Input.txt contains cat ss.txt 100|2009-03-30 11:38:43 141|2009-06-01 12:12:01... (1 Reply)
Discussion started by: sureshg_sampat
1 Replies

2. UNIX for Dummies Questions & Answers

Shell script which will sort all the files in a directory with the timestamp they were created

Team, Pls help writing a shell script which will sort all the files in a directory with the timestamp they were created. (like ls -lrt) (6 Replies)
Discussion started by: asappidi
6 Replies

3. Shell Programming and Scripting

Getting a relative timestamp from timestamp stored in a file

Hi, I've a file in the following format 1999-APR-8 17:31:06 1500 3 45 1999-APR-8 17:31:15 1500 3 45 1999-APR-8 17:31:25 1500 3 45 1999-APR-8 17:31:30 1500 3 45 1999-APR-8 17:31:55 1500 3 45 1999-APR-8 17:32:06 1500 3 ... (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

4. UNIX for Dummies Questions & Answers

How to compare a file by its timestamp and store in a different location whenever timestamp changes?

Hi All, I am new to unix programming. I am trying for a requirement and the requirement goes like this..... I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Discussion started by: mailsara
2 Replies

5. Programming

Sort the files on their name and then the timestamp using Perl

Hi All, I am new to Perl. I have a scenario to code. In a folder I have number of files and they will start with P01 or P02 or P03 and so on..I have to sort them on name first and then on time stamp. Ex. File name timestamp P01_file1.txt 1PM P02_file1.txt 1AM P01_file2.txt 2PM... (12 Replies)
Discussion started by: unankix
12 Replies

6. Shell Programming and Scripting

How to sort grep result based on timestamp?

Hi, Trying to sort grep result based on timestamp of the filename. I have the following result and want to sort them on timestampgrep -i 'ERROR' *log*2013* s_m_xxx_xxx_xxx_xxx_xxxx.log.20130906092431:TRANSF_1_1_1> DBG_21216 Finished transformations for Source Qualifier . Total errors ... (5 Replies)
Discussion started by: bobbygsk
5 Replies

7. Shell Programming and Scripting

How to sort the timestamp in the filename in shell script?

originally the shellscript #ln_file_name=`echo $ld_interface_date"_"${8}".csv"` #ln_file_name=`echo 201202011527_HL_HLTM1_B04A.csv` ln_file_name="*"`echo ${7}".csv"` get_file_list_1=$log_path"tm1_file_list.gfl1" cd ${source_path} echo "Try to find any file exist in the... (10 Replies)
Discussion started by: feilhk
10 Replies

8. Shell Programming and Scripting

Sort Unique Column with the most recent timestamp

Hello, I have a sample file with the below contents : Backup Oracle8_P112_PEGA_Archivedel Completed full 10/11/2015 03:50:06PM Backup Oracle8_G567_PEGA_Archivedel Completed full 10/11/2015 01:15:56PM Backup Oracle8_P112_PEGA_Archivedel Completed full ... (8 Replies)
Discussion started by: rahul2662
8 Replies

9. Shell Programming and Scripting

Find files and sort by timestamp

Used below command to get list of files sorted by timestamp find -L . -type f -name '*dat*' | xargs ls -ltrg I want to get only the filenames so I tried adding basename but it doenst work , can some one advise on how to get only file name (1 Reply)
Discussion started by: lalitpct
1 Replies
PESCETTI(1)						      General Commands Manual						       PESCETTI(1)

NAME
pescetti -- Pseudo-Duplimate Generator SYNOPSIS
pescetti DESCRIPTION
This manual page documents briefly the pescetti command. OPTIONS
Here are a list of the available options and what they do. You must specify exactly one from --demo, --generate or --load. --help Prints the help text --demo Demonstration mode. Generates one hand with permutations and the tutorial for how to use them. --generate=N Generate N random boards --load=boards.txt Load boards+analysis from boards.txt --load-dds=boards.dds Load boards from boards.dds in dds format --load-analysis=tricks.txt Load analysis from tricks.txt --permutations=permutations.txt Generate the permutations and save them to the given file --curtains=curtains.txt Save curtain cards to file curtains.txt --save=boards.txt Save the boards+analysis to boards.txt --save-dds=boards.dds Save the boards to boards.dds in dds format --save-analysis=tricks.txt Save the analysis to tricks.txt --format=html|txt|pdf Set the output mode to the given format --title=title Set the title for the output --output=hands.txt Print the hands to hands.txt, rather than to standard output --stats Generate statistics about the set of boards; included in the hands output --analyze Run the dds analyzer on the boards and print the resulting numberof tricks (warning SLOW) --criteria= A list of criteria to apply to each generated hand to generate specific hand types. The list should be space separated and each item may be suffixed with a colon and a (fractional) probability value which can be used to weight the criteria. E.g. --criteria="weaknt:0.8 strongnt:0.5" Valid criteria are: unbalanced weaknt strongnt twont strongtwo weaktwo three twoclubs 4441 singlesuit twosuits partscore game slam game-invite slam-invite jumpshift jumpfit splinter bacon weird --probability=factor Generate hands matching the criteria with only the given probability. Factor is in the range 0 to 1. On each attempt to generate a board it is rejected if it doesn't match the criteria with the given probability. A factor of about 0.8 gives roughly half matching boards AUTHOR
This manual page was written by Matthew Johnson <debian@matthew.ath.cx>. Permission is granted to copy, distribute and/or modify this docu- ment under the terms of the GNU General Public License, Version 2 as published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. PESCETTI(1)
All times are GMT -4. The time now is 09:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy