Sponsored Content
Full Discussion: Require help to sort string
Top Forums Shell Programming and Scripting Require help to sort string Post 302370140 by sathik on Wednesday 11th of November 2009 02:21:12 AM
Old 11-11-2009
Quote:
Originally Posted by methyl
If this is to be a regular process it is very complex because of the alphabetic month abbreviations and the absence of the year in the data.
Surely this would be better as a full blown SQL program which could deduce the year, translate the data into a sortable format, sort to order and run the required SQL.

Hi methyl,

or I can select another one column also with that partition name as below.

SQL> select partition_name,high_value from user_tab_partitions where table_name='USER_AUDIT';
PARTITION_NAME HIGH_VALUE
------------------------------ --------------------------------------------------------------------------------
PARTMAX MAXVALUE
SAS_AUDIT_NOV02 TO_DATE(' 2009-11-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SAS_AUDIT_NOV08 TO_DATE(' 2009-11-08 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SAS_AUDIT_NOV14 TO_DATE(' 2009-11-14 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SAS_AUDIT_OCT27 TO_DATE(' 2009-10-27 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA

is there any way to sort with the help of high value column?

---------- Post updated 11-11-09 at 02:21 AM ---------- Previous update was 11-10-09 at 01:26 PM ----------

hi Folks,

Can anybody help me to sort the below output?

PARTITION_NAME HIGH_VALUE
------------------------------ --------------------------------------------------------------------------------
SAS_AUDIT_NOV02 TO_DATE(' 2009-11-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SAS_AUDIT_NOV08 TO_DATE(' 2009-11-08 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SAS_AUDIT_NOV14 TO_DATE(' 2009-11-14 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SAS_AUDIT_OCT27 TO_DATE(' 2009-10-27 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA

This output will be stored in a file. From that I can print the date only as below by using cat output.lst|awk '{print $3}'|sort -n

2009-10-27
2009-11-02
2009-11-08
2009-11-14

Now I need to take the partition_ name of oldest date. In this scenario, the oldest date is 2009-10-27 and corresponding partition_name is SAS_AUDIT_OCT27. So I need the output as below.

Required output:
============
SAS_AUDIT_OCT27
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to sort a string with numbers

Hi, I need help to sort a file contents. I am using sort -r option to basically reverse the comparison in descending order. However, i found out that my file is not sorted according, can anyone please help. My data is something like:- Hello world 20.982342864 343 19.234355545 222... (5 Replies)
Discussion started by: ahjiefreak
5 Replies

2. Shell Programming and Scripting

sort entire line based on part of the string

hey gurus, my-build1-abc my-build10-abc my-build2-abc my-build22-abc my-build3-abc basically i want to numerically sort the entire lines based on the build number. I dont zero pad the numbers because thats "how it is" ;-) sort -n won't work because it starts from the beginning. ... (10 Replies)
Discussion started by: gurpal2000
10 Replies

3. Shell Programming and Scripting

Sort based on string lenght.

I'm not familiar with find. If i use find in a certain directory i want it to show based on hierarchy. find . type d fol1 fol1/subfol1 fol1/subfol1/subfol1 fol2 fol2/subfol2 i want it to show like this fol1/subfol1/subfol1 fol1/subfol1 fol1 fol2/subfol2 fol2 do i need to use... (5 Replies)
Discussion started by: ryandegreat25
5 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. Shell Programming and Scripting

Remove duplicate chars and sort string [SED]

Hi, INPUT: DCBADD OUTPUT: ABCD The SED script should alphabetically sort the chars in the string and remove the duplicate chars. (5 Replies)
Discussion started by: jds93
5 Replies

6. Shell Programming and Scripting

how to sort lines in the string

Hi guys, I am trying to sort numbers in the string in descending order but for some reason sort fails. n129$ echo "81 240" | sort -r 81 240 n129$ I am not sure what am I doing wrong. Is there a 100% reliable way to make sure that sort will always work. I mean on SUNS and IBM machines. ... (4 Replies)
Discussion started by: aoussenko
4 Replies

7. Shell Programming and Scripting

Sort a hash based on the string length of the values

Hi, I want to be able to sort/print a hash based on the string length of the values. For example %hash = ( key1 => 'jeri', key2 => 'corona', key3 => 'una, ); I want to be able to print in the following order (smallest to largest) una,jeri,corona OR... (1 Reply)
Discussion started by: jdilts
1 Replies

8. Shell Programming and Scripting

Sort String using awk

Hi, I need help to sort string using awk. I don't want to use sed or perl as I want to add this functionality in my existing awk script Basically I have a variable in AWK which is string with comma separated value. I want to sort that string before using that variable in further processing for... (10 Replies)
Discussion started by: rocky.community
10 Replies

9. Shell Programming and Scripting

Sort only numbers within a string

Hi, I am having contents in a file like below, cat testfile rpool/swap rpool/swap14 rpool/swap2 rpool/swap3 I want to sort the above contents like, rpool/swap rpool/swap2 rpool/swap3 rpool/swap14 I have tried in this way, (7 Replies)
Discussion started by: Sumanthsv
7 Replies

10. Shell Programming and Scripting

Sort file data according to a custom list of string

I have a string of pre defined ip address list which will always remain constant their order will never change like in below sample: iplist=8.8.5.19,9.7.5.14,12.9.9.23,8.8.8.14,144.1.113 In the above example i m considering only 5 ips but there could be many more. Now i have a file which... (15 Replies)
Discussion started by: mohtashims
15 Replies
Convert::NLS_DATE_FORMAT(3pm)				User Contributed Perl Documentation			     Convert::NLS_DATE_FORMAT(3pm)

NAME
Convert::NLS_DATE_FORMAT - Convert Oracle NLS_DATE_FORMAT <-> strftime Format Strings SYNOPSIS
use Convert::NLS_DATE_FORMAT qw(oracle2posix posix2oracle); my $strptime = oracle2posix($NLS_DATE_FORMAT); $NLS_DATE_FORMAT = posix2oracle($strftime); DESCRIPTION
Convert Oracle's NLS_DATE_FORMAT string into a strptime format string, or the reverse. Functions oracle2posix Takes an Oracle NLS_DATE_FORMAT string and converts it into formatting string compatible with "strftime" or "strptime". my $format = oracle2posix('YYYY-MM-DD HH24:MI:SS'); # '%Y-%m-%d %H:%M:%S' Character sequences that should not be translated may be enclosed within double quotes, as specified in the Oracle documentation. my $format = oracle2posix('YYYY-MM-DD"T"HH24:MI:SS'); # '%Y-%m-%dT%H:%M:%S' posix2oracle Takes a "strftime" or "strptime" formatting string and converts it into an Oracle NLS_DATE_FORMAT string. It is possible to create strings which Oracle will not accept as valid NLS_DATE_FORMAT strings. my $format = posix2oracle('%Y-%m-%d %H:%M:%S'); # 'YYYY-MM-DD HH24:MI:SS' EXPORT None by default. "oracle2posix" and "posix2oracle" when asked. SEE ALSO
DateTime::Format::Oracle. AUTHOR
Nathan Gray, <kolibrie@cpan.org> COPYRIGHT AND LICENSE
Copyright (C) 2005, 2006, 2011, 2012 Nathan Gray This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available. perl v5.14.2 2012-01-18 Convert::NLS_DATE_FORMAT(3pm)
All times are GMT -4. The time now is 04:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy