Sponsored Content
Top Forums UNIX for Dummies Questions & Answers List the directories, having given pattern in the directories name, sorted by creation date Post 302802775 by Siva SQL on Saturday 4th of May 2013 09:07:53 PM
Old 05-04-2013
HP List the directories, having given pattern in the directories name, sorted by creation date

It is for HP-Unix B.11.31.

Requirement:

1. List the directories, having given pattern in the directories name, sorted by creation date.
Example: Directories with name "pkg32*" or "pkg33*"

2. On the output of 1. list the directories by creation date as sort order, with creation date display in mm/dd/yyyy format

I tried with;
Code:
find ./ -name "pkg3[23]*" -type d | xargs ls -ld
find ./ -name "pkg3[23]*" -type d -exec ls -ld {} \; | awk '{print $6,$7,$8,$9}'

But I want the output to be sorted with creation date;

Code:
$ find ./ -name "pkg3[2]*" -type d -exec ls -ld {} \; | awk '{print $6,$7,$8,$9}'
Oct 24 2012 ./pkg320.0_20121025_mrg
Oct 25 2012 ./pkg320.0_20121025_fix
Oct 31 2012 ./pkg320.0_20121101
Oct 31 2012 ./pkg320.0_20121101_ret
Nov 4 2012 ./pkg320.0_dev02_20121104
Nov 7 23:24 ./pkg320.0_20121108
Nov 13 19:57 ./pkg320.0_20121114
Nov 29 13:56 ./pkg320.0_20121004_prof
Nov 29 13:56 ./pkg320.0_20121129_fix
Nov 28 14:42 ./pkg320.0_20121101_prof
Nov 28 14:43 ./pkg320.0_20121108_prof
Nov 29 15:31 ./pkg320.0_20121129_fix1
Dec 7 12:51 ./pkg321.0_20121207_56
Dec 11 15:06 ./pkg321.0_20121211_CR5875
Dec 4 21:48 ./pkg321.0_20121205
Dec 11 23:03 ./pkg321.0_20121212
Dec 11 23:05 ./pkg321.0_20121212_ret
Dec 14 11:02 ./pkg321.0_20121214_CR_fix
Dec 17 09:53 ./pkg321.0_20121217_fix
Dec 17 10:08 ./pkg321.0_20121216_fix
Dec 19 15:57 ./pkg321.0_20121219
Dec 31 23:50 ./pkg322.0_20130102
Jan 9 09:56 ./pkg322.0_20130109
Jan 9 09:57 ./pkg322.0_20130109_ret
Jan 11 11:28 ./pkg322.0_20130111_fix
Jan 16 10:41 ./pkg322.1_20130116_ret
Jan 23 21:12 ./pkg322.3_20130124
Feb 12 22:18 ./pkg322.6_20130212_ret
Mar 19 16:30 ./pkg321.0_20121205_prof
Mar 19 17:51 ./pkg321.0_20121212_prof
Mar 19 18:32 ./pkg322.0_20130102_prof
May 1 2012 ./pkg320.0_dev02_20120205
May 1 2012 ./pkg320.0_dev02_20120401
Jul 6 2012 ./pkg320.0_dev02_20120708
Aug 3 2012 ./pkg320.0_dev02_20120805

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creation of multiple directories

I have a folder structure like the below /test/test1/test2/app /test/test3/app /test/test4/test5/app .. I need to create a new folder under "app" in all the above listed directory structure at one shot by the name "subapp" . How can we acheive this using a script . New to unix... (4 Replies)
Discussion started by: rajeshnatarajan
4 Replies

2. Shell Programming and Scripting

How to list all the directories, sub directories in a mount along with size in ascending order?

Hi , I am very new to unix as well as shell scripting. I have to write a script for the following requirement. In a particular mount, have to list all the directories and sub directories along with size of the directory and sub directory in ascending order. Please help me in this regard and many... (4 Replies)
Discussion started by: nmakkena
4 Replies

3. UNIX for Dummies Questions & Answers

List directories and sub directories recursively excluding files

Hi, Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process. I wanted to disply using a unix command all the directories recursively excluding files. I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies

4. UNIX for Dummies Questions & Answers

List directories with given string, sort by creation date

It is for HP-Unix B.11.31. Requirement: 1. List the directories, which directories name has given particular string. Example: Directories with name "Build" 2. On the output of 1. list the directories by creation date as sort order. I tried with; find . -type d -name "Build*" ... (3 Replies)
Discussion started by: Siva SQL
3 Replies

5. UNIX for Dummies Questions & Answers

Using grep command to find the pattern of text in all directories and sub-directories.

Hi all, Using grep command, i want to find the pattern of text in all directories and sub-directories. e.g: if i want to search for a pattern named "parmeter", i used the command grep -i "param" ../* is this correct? (1 Reply)
Discussion started by: vinothrajan55
1 Replies

6. HP-UX

Symbolic link creation between 2 directories on different machines

I am trying to link 2 directories using: ln -s /net/<hostname>/srcdir/ /net/<desthostname>/dstdir/ I get the following error: ln: /net/<desthostname>/dstdir: Function is not available What is it that i am trying to do wrongly in the above operation? Please use next time code tags (3 Replies)
Discussion started by: Amit Kulkarni
3 Replies

7. Shell Programming and Scripting

Automating creation of directories

I have a top-level directory called work and I would like to create subdirectories work1 work2... under this directory. Also I would like to create subdirectory under work1 -- test, work2 -- test etc., Can I automate this using a command-line script? work |_work 1 |_test |_work 2 ... (2 Replies)
Discussion started by: sharone
2 Replies

8. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

9. Shell Programming and Scripting

[Solved] Creation of directories

i am having trouble creating a directory with last months date as the folder name. what i am using is echo `date +%b%y` which gives Mar14 as the result but i want to get Feb14 as the result.:wall: (6 Replies)
Discussion started by: simkazw
6 Replies

10. UNIX for Beginners Questions & Answers

List all files and directories in the current directory separated by commas and sorted by crtime

What I know so far: ls -A will list all files except those starting with a dot ls -d will list all directories ls -m will separate contents by commas For getting crtimes use: stat filename will give me the inode number or ls -i filename will give... (13 Replies)
Discussion started by: chstewar
13 Replies
SORTM(1)							     [nmh-1.5]								  SORTM(1)

NAME
sortm - sort messages SYNOPSIS
sortm [+folder] [msgs] [-datefield field] [-textfield field] [-notextfield] [-limit days] [-nolimit] [-verbose | -noverbose] [-version] [-help] DESCRIPTION
Sortm sorts the specified messages in the named folder according to the chronological order of the "Date:" field of each message. The -verbose switch directs sortm to tell the user the general actions that it is taking to place the folder in sorted order. The -datefield field switch tells sortm the name of the field to use when making the date comparison. If the user has a special field in each message, such as "BB-Posted:" or "Delivery-Date:", then the -datefield switch can be used to direct sortm which field to examine. The -textfield field switch causes sortm to sort messages by the specified text field. If this field is "subject", any leading "re:" is stripped off. In any case, all characters except letters and numbers are stripped and the resulting strings are sorted datefield-major, textfield-minor, using a case insensitive comparison. With -textfield field, if -limit days is specified, messages with similar textfields that are dated within `days' of each other appear together. Specifying -nolimit makes the limit infinity. With -limit 0, the sort is instead made textfield-major, date-minor. For example, to order a folder by date-major, subject-minor, use: sortm -textfield subject +folder FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder SEE ALSO
folder(1) DEFAULTS
`+folder' defaults to the current folder `msgs"'defaultstoall" `-datefield' defaults to date `-notextfield' `-noverbose' `-nolimit' CONTEXT
If a folder is given, it will become the current folder. If the current message is moved, sortm will preserve its status as current. HISTORY
Timezones used to be ignored when comparing dates: they aren't any more. Messages which were in the folder, but not specified by `msgs', used to be moved to the end of the folder; now such messages are left untouched. Sortm sometimes did not preserve the message numbering in a folder (e.g., messages 1, 3, and 5, might have been renumbered to 1, 2, 3 after sorting). This was a bug, and has been fixed. To compress the message numbering in a folder, use "folder -pack" as always. BUGS
If sortm encounters a message without a date-field, or if the message has a date-field that sortm cannot parse, then sortm attempts to keep the message in the same relative position. This does not always work. For instance, if the first message encountered lacks a date which can be parsed, then it will usually be placed at the end of the messages being sorted. When sortm complains about a message which it can't temporally order, it complains about the message number prior to sorting. It should indicate what the message number will be after sorting. MH.6.8 11 June 2012 SORTM(1)
All times are GMT -4. The time now is 11:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy