Arranging files in order of files_digits


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Arranging files in order of files_digits
# 8  
Old 10-19-2012
Hi, sorry I forgot to mention.
The following worked fine:
Code:
  ls -lt | awk -F_ '{print $3,$0}' OFS=\t | sort -n | cut -f2-


Emily,
# 9  
Old 10-19-2012
Quote:
Originally Posted by emily
Hi all,
I have input files in some directory as:

Code:
$ ls -ltr
 -rw-r--r-- 1 emily us_cms 101614219 Oct  8 15:47 vgtree_197_0_7pV.root
-rw-r--r-- 1 emily us_cms 101348458 Oct  8 16:43 vgtree_518_0_LHB.root
-rw-r--r-- 1 emily us_cms 101386298 Oct  8 16:50 vgtree_291_0_cWd.root
-rw-r--r-- 1 emily us_cms 101551150 Oct  8 16:53 vgtree_289_0_JSf.root
-rw-r--r-- 1 emily us_cms 101348458 Oct  8 17:04 vgtree_518_0_YTs.root
-rw-r--r-- 1 emily us_cms 101481802 Oct  8 17:07 vgtree_251_0_N6T.root
-rw-r--r-- 1 emily us_cms 101309649 Oct  8 17:07 vgtree_198_0_bCn.root
-rw-r--r-- 1 emily us_cms 101349505 Oct  9 07:07 vgtree_575_0_6RT.root
-rw-r--r-- 1 emily us_cms 101716996 Oct  9 08:54 vgtree_517_1_sE7.root
-rw-r--r-- 1 emily us_cms 101423961 Oct  9 10:06 vgtree_122_0_7g2.root
-rw-r--r-- 1 emily us_cms 101473618 Oct  9 10:10 vgtree_187_0_aa1.root
-rw-r--r-- 1 emily us_cms 101481802 Oct  9 11:56 vgtree_251_0_Y2E.root
-rw-r--r-- 1 emily us_cms 101366281 Oct  9 14:17 vgtree_320_1_2me.root
-rw-r--r-- 1 emily us_cms 101632226 Oct  9 14:58 vgtree_240_1_E5S.root
-rw-r--r-- 1 emily us_cms 101852105 Oct  9 15:11 vgtree_501_0_z5T.root
-rw-r--r-- 1 emily us_cms 101283966 Oct  9 16:10 vgtree_257_1_tiq.root
-rw-r--r-- 1 emily us_cms 101600046 Oct  9 22:18 vgtree_281_1_WFP.root
-rw-r--r-- 1 emily us_cms 101372192 Oct  9 22:19 vgtree_317_1_TpA.root
-rw-r--r-- 1 emily us_cms 101558034 Oct  9 23:20 vgtree_265_1_OQN.root
-rw-r--r-- 1 emily us_cms 101460480 Oct 16 10:45 vgtree_256_1_UtH.root

Quote:
Originally Posted by emily
Hi, sorry I forgot to mention.
The following worked fine:
Code:
  ls -lt | awk -F_ '{print $3,$0}' OFS=\t | sort -n | cut -f2-

Be aware that changes in ownership (user and/or group) can break this solution.

On which operating system(s) must the solution run?

Regards,
Alister

Last edited by alister; 10-19-2012 at 01:04 PM..
# 10  
Old 10-19-2012
Hi Alister,
That is not problem right now. I can take care that.
just wondering if manage to do complete task with script than doing it manually.
# 11  
Old 10-19-2012
Quote:
Originally Posted by alister
On which operating system(s) must the solution run?
It matters. Some find implementations have functionality that make this a trivial task (as hinted by delugeag in post #5).

Regards,
Alister
# 12  
Old 10-19-2012
Ohh,
Presently it worked fine for me. Basically it is remote machine, but they are Linux based.
And shell is bash.
thansk
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Loop Through Files in Order and mapping

Hi there, How can I loop through files with order. I tried using ls .html | sort -v However the filename is with spaces:1233.61.47.0 - 121.61.123.112 nexpose.html Here is the original code that is working well, but I need to sort through the filename.echo "<center>" for file in *.html... (2 Replies)
Discussion started by: alvinoo
2 Replies

2. Shell Programming and Scripting

How to list files in ascending order?

Hi, I need to list files in ascending order. Filenames are in format inpTDT_1, inpTDT_2, inpTDT_3 and so on. I want to list them in the ascending order based on the digit after underscore and send the output to a file. Please help (5 Replies)
Discussion started by: Neelkanth
5 Replies

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

4. UNIX for Advanced & Expert Users

Uploading files in chronological order

Thanks for your help. (3 Replies)
Discussion started by: circuit.muni
3 Replies

5. UNIX for Advanced & Expert Users

merge two files in ascending order

Hello Friends, I want to merge two files in ascending order on the first field. And if the first field matches sort on 3rd field i.e, TXADDR should come ahead of RXADDR . file1 9 : TXADDR : 00000000 65 : TXDATA 0000000000000011 83 : TXDATA 0000000000000012 453 :... (10 Replies)
Discussion started by: user_prady
10 Replies

6. Shell Programming and Scripting

Arranging files

Hi all, This is program to identify and arrange programs(scripts) based on their she-bang values to a folder with the same name. The parts of mkdir and copy and creating problems.I also doubt the use of hash...maybe some problems in it. Please help out debugging this. Code pasted at: Paste... (2 Replies)
Discussion started by: Vivek788
2 Replies

7. Shell Programming and Scripting

Comparing files enen when they are not in order

Hi, I have two master files which contain the information for many jobs like this Job no:1 a b c d Job no:1 d e g h Job no:2 t j s h Job no:2 t j s h I have written a script to pick up all the information for Job no:1 from file1 and put that to a temporary file and do the same from... (2 Replies)
Discussion started by: ragavhere
2 Replies

8. UNIX for Dummies Questions & Answers

list of files in date order

Im on HP/UX and am trying to find the command like an ll but that will sort showing the most currently modified programs first. Can anyone help me with that? :cool: (2 Replies)
Discussion started by: Jeannine
2 Replies

9. Shell Programming and Scripting

Listing files in numerical order

Hi, I'm trying to write a ksh script to copy a specified number of files from one directory to another. The files are named in the convention <switchname>_log.<num> and the numbers are sequential single digit onwards. I figured I could find some parameter for ls which would list the files in... (3 Replies)
Discussion started by: Steve_H
3 Replies

10. UNIX for Advanced & Expert Users

lp - order of files printed

I have a shell script that is looping through a list of Postscript files to print. ls -1tr *.PS > print.lst ... PRINT_LIST=`cat print.lst` ... for DMFILE in $PRINT_LIST do lp -d $PRINTER_NAME -o legal $DMFILE ... done The files in print.lst are in the order that they should be... (2 Replies)
Discussion started by: mabrownawa
2 Replies
Login or Register to Ask a Question