Sponsored Content
Full Discussion: sort files
Top Forums Shell Programming and Scripting sort files Post 302331829 by Elii on Tuesday 7th of July 2009 09:27:57 AM
Old 07-07-2009
sort files

i have a folder contails 3 types of files ,
ls -l
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 aml001.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 aml002.agl
-rw-r--r-- 1 oratest dba 6 Jul 1 15:43 aml003.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 bom001.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 bom002.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:44 bom003.agl
-rw-r--r-- 1 oratest dba 8 Jul 1 15:35 item001.agl
-rw-r--r-- 1 oratest dba 9 Jul 1 15:35 item002.agl
-rw-r--r-- 1 oratest dba 8 Jul 1 15:43 item003.agl

aml , bom , item

i want a script which sort the files by the number after the name,
i want to get the following result after the sort command:

-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 aml001.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 bom001.agl
-rw-r--r-- 1 oratest dba 8 Jul 1 15:35 item001.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 aml002.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:36 bom002.agl
-rw-r--r-- 1 oratest dba 9 Jul 1 15:35 item002.agl
-rw-r--r-- 1 oratest dba 6 Jul 1 15:43 aml003.agl
-rw-r--r-- 1 oratest dba 7 Jul 1 15:44 bom003.agl
-rw-r--r-- 1 oratest dba 8 Jul 1 15:43 item003.agl

all 001 files will be first , then 002 files and so

the number could be with 4 digits and 5 ...


thanks
 

10 More Discussions You Might Find Interesting

1. 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

2. UNIX for Dummies Questions & Answers

sort files

Hi Can some one help me with sorting a file where i am supposed to sort based on the last column(i.e 3rd column) and then by 1 st column Sample data 2 ishika 4 5 suj 3 10 raj 4 23 fff 3 45 amar 4 to be sorted to 5 suj 3 23 fff 3 2 ishika 4 10 raj 4 45 amar 4 I tried to sort... (2 Replies)
Discussion started by: mita10
2 Replies

3. 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

4. UNIX for Dummies Questions & Answers

Merge files and sort them

hi all, i have three files naming file1 , file2, file3 . i want to merge the content of these three files, sort them and display the sorted output on the screen page by page. (1 Reply)
Discussion started by: sonu_pal
1 Replies

5. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

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

6. Shell Programming and Scripting

Sort and output to different files

Hi all! I have a comma delimited file and I'm sorting it based on fields 6, 8 and 10. The following does the job: sort -t, -nk6,10 unsorted.txt -o sorted.txt What I need to do now is to write every row containing same values on fields 6, 8 and 10 to a different file. Any ideas on how to do... (2 Replies)
Discussion started by: Tr0cken
2 Replies

7. Shell Programming and Scripting

sort the files based on timestamp and execute sorted files in order

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)
Discussion started by: saidutta123
1 Replies

8. Shell Programming and Scripting

How to sort the files according to the number?

Hi Everyone, I have a question: I have a lot of file named like or10000.dat, or9100.dat, or100.dat, or3100.dat... I want to deal with these files according to the number in the name. So I want to deal with or100.dat first and then or3100.dat and so on. I used : for i in `ls or*.dat |... (11 Replies)
Discussion started by: wxuyec
11 Replies

9. UNIX for Beginners Questions & Answers

Sort files to the split second

I need a similar sort, I need to sort the directory by time, but time needs to be to the second or smaller. Using ls -lt but that is only to the minute. (3 Replies)
Discussion started by: mwlaursen
3 Replies

10. UNIX for Beginners Questions & Answers

How to sort these files?

Hi, An ls outputs this -rw-rw-rw- 1 jeisma users 0 Aug 8 09:24 file.d1 -rw-rw-rw- 1 jeisma users 0 Aug 8 09:24 file.d10 -rw-rw-rw- 1 jeisma users 0 Aug 8 09:24 file.d11 -rw-rw-rw- 1 jeisma users 0 Aug 8 09:25 file.d2... (3 Replies)
Discussion started by: jeisma
3 Replies
CUBRID_PCONNECT_WITH_URL(3)						 1					       CUBRID_PCONNECT_WITH_URL(3)

cubrid_pconnect_with_url - Open a persistent connection to CUBRID server

SYNOPSIS
resource cubrid_pconnect_with_url (string $conn_url, [string $userid], [string $passwd]) DESCRIPTION
Establishes a persistent connection to a CUBRID server. cubrid_pconnect_with_url(3) acts very much like cubrid_connect_with_url(3) with two major differences. First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, port, dbname and userid. If one is found, an identifier for it will be returned instead of opening a new connection. Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (cubrid_close(3) or cubrid_disconnect(3) will not close links established by cubrid_pconnect_with_url(3)). This type of link is therefore called 'persistent'. <url> ::= CUBRID:<host>:<db_name>:<db_user>:<db_password>:[?<properties>] <properties> ::= <property> [&<property>] <properties> ::= alhosts=<alternative_hosts>[ &rctime=<time>] <properties> ::= login_timeout=<milli_sec> <properties> ::= query_timeout=<milli_sec> <properties> ::= disconnect_on_query_timeout=true|false <alternative_hosts> ::= <standby_broker1_host>:<port> [,<standby_broker2_host>:<port>] <host> := HOSTNAME | IP_ADDR <time> := SECOND <milli_sec> := MILLI SECOND ohost : A host name or IP address of the master database odb_name : A name of the database odb_user : A name of the database user odb_password : A database user password o alhosts : Specifies the broker information of the standby server, which is used for failover when it is impossible to connect to the active server. You can specify multiple brokers for failover, and the connection to the brokers is attempted in the order listed in alhosts o rctime : An interval between the attempts to connect to the active broker in which failure occurred. After a failure occurs, the system connects to the broker specified by althosts (failover), terminates the transaction, and then attempts to connect to the active broker of the master database at every rctime. The default value is 600 seconds. o login_timeout : Timeout value (unit: msec.) for database login. The default value is 0, which means infinite postponement. o query_timeout : Timeout value (unit: msec.) for query request. Upon timeout, a message to cancel requesting a query transferred to server is sent. The return value can depend on the disconnect_on_query_timeout configuration; even though the message to cancel a request is sent to server, that request may succeed. o disconnect_on_query_timeout : Configures a value whether to immediately return an error of function being executed upon timeout. The default value is false. Note ? and : that are used as identifiers in PHP connection URL can't be included in the password. The following is an example of a pass- word that is invalid to use as connection URL because it contains " ?:". $url = "CUBRID:localhost:33000:tdb:dba:12?:?login_timeout=100"; Passwords that contain ? or : may be passed as a separate parameter. $url = "CUBRID:localhost:33000:tbd:::?login_timeout=100"; $conn = cubrid_pconnect_with_url ($url, "dba", "12?"); If user or password is empty,you can't delete " :",the following is an example. $url = "CUBRID:localhost:33000:demodb:::"; PARAMETERS
o $conn_url -A character string that contains server connection information. o $userid -User name for the database. o $passwd -User password. RETURN VALUES
Connection identifier, when process is successful. FALSE, when process is unsuccessful. EXAMPLES
Example #1 cubrid_pconnect_with_url(3) url without properties example <?php $conn_url = "CUBRID:127.0.0.1:33000:demodb:dba::" $con = cubrid_pconnect_with_url ($conn_url); if ($con) { echo "connected successfully"; cubrid_execute($con, "create table person(id int,name char(16))"); $req =cubrid_execute($con, "insert into person values(1,'James')"); if ($req) { cubrid_close_request ($req); cubrid_commit ($con); } else { cubrid_rollback ($con); } cubrid_disconnect ($con); } ?> Example #2 cubrid_pconnect_with_url(3) url with properties example <?php $conn_url = "CUBRID:127.0.0.1:33000:demodb:dba::?althost=10.34.63.132:33088&rctime=100" $con = cubrid_pconnect_with_url ($conn_url); if ($con) { echo "connected successfully"; $req =cubrid_execute($con, "insert into person values(1,'James')"); if ($req) { cubrid_close_request ($req); cubrid_commit ($con); } else { cubrid_rollback ($con); } cubrid_disconnect ($con); } ?> SEE ALSO
cubrid_connect(3), cubrid_pconnect(3), cubrid_pconnect_with_url(3), cubrid_disconnect(3), cubrid_close(3). PHP Documentation Group CUBRID_PCONNECT_WITH_URL(3)
All times are GMT -4. The time now is 06:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy