Sorting with list, - 2 lists next to 200


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sorting with list, - 2 lists next to 200
# 1  
Old 03-19-2014
Sorting with list, - 2 lists next to 200

Hi I was wondering if anyone knew the best way to have files displayed by list so that they were in numerical order?
the problem I am having is I am using the ls and the head command to sort a group of 500 files into manageable 133 file bunches and transfer them to another directory were they will be processed by another program.
This is an example of the file name "OPS-order-326-item-PM447_Quantity_6_of_500_front.p1.p1.pdf"
All the files stay in order until the Quantity number changes from one digit to two, then the sort displays with Quantity_2 next to Quantity_200
"OPS-order-326-item-PM447_Quantity_2_of_500_front.p1.p1.pdf being next to
"OPS-order-326-item-PM447_Quantity_200_of_500_front.p1.p1.pdf
Is there a better way to do this outside of having leading zeros in my quantity number?
Below is the command that I am using
Code:
ls /somefiles/*.pdf | head -133 | xargs -I{} mv {} /A_place_to_put_somefiles

# 2  
Old 03-19-2014
Are they created in numerical order as well? You could just list by (reverse) date order - ls -tr.
# 3  
Old 03-19-2014
Hi unfortunately that wont work is there a way I can use the version option to see just the OPS-order-326-item-PM447_Quantity_"2" or OPS-order-326-item-PM447_Quantity_"200" as the version number?
Thanks
# 4  
Old 03-19-2014
Not sure if this will work:
Code:
ls -1 /somefiles/*.pdf | sort --field-separator=_ --key=f3 --numeric-sort | head -133

should give you a list of the files in numeric order. You can then append the | xargs -I{} mv {} /A_place_to_put_somefiles bit if it works.

Andrew
# 5  
Old 03-19-2014
Hi thanks very much your helps was much appreciated.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with split a list of records into each line with 200 coordinate at a time

Input File: E 3359799 3360148 350 X D 3471287 3471607 321 X E 3359799 3360740 942 X E 4359790 4360039 250 X . . . Desired Output File: E 3359799 3359998 200 X E 3359999 3360148 150 X D 3471287 3471486 200 X D 3471487 3471607 121 X E 3359799 3359998 200 X E 3359999 3360198 200 X... (1 Reply)
Discussion started by: perl_beginner
1 Replies

2. Shell Programming and Scripting

Sorting a list of words one per line by their ending

Hello, My OS is Windows and therefore DOS. Hence I have no access to Unix tools. I am trying to sort a file in Urdu by the character by which it ends. Each word is on a separate line. As input, an example in English would help: fruit banana apple pear house I need the sort to be on the... (5 Replies)
Discussion started by: gimley
5 Replies

3. Shell Programming and Scripting

Sorting a list

I am trying to sort a list If you walk through the list, every you have passed both website1 and website2 and get back to website1, the last lines should be collected into one line and the process should start again. The following: http://www.website1.com http://www.website1.com... (2 Replies)
Discussion started by: locoroco
2 Replies

4. Shell Programming and Scripting

Perl: Sorting a hash value that is a list.

Hi Folks I am very much a newbie at perl but picking it up and I'm hoping you can help. I have a file input that details all the /etc/group files in our enterprise in the following format: "<host>:<group>:<gid>:<users>" I want to parse this data display it as the following:... (9 Replies)
Discussion started by: g_string
9 Replies

5. UNIX for Dummies Questions & Answers

Sorting a list

n02-z30-dsr65-terr0.50-dc0.010-16x12drw-run1.cmd n02-z30-dsr65-terr0.50-dc0.008-16x12drw-run1.cmd n02-z30-dsr65-terr0.50-dc0.006-16x12drw-run1.cmd n02-z30-dsr65-terr0.50-dc0.004-16x12drw-run1.cmd n02-z30-dsr65-terr0.50-dc0.002-16x12drw-run1.cmd n02-z30-dsr65-terr0.50-dc0.006-16x12drw-run2.cmd... (13 Replies)
Discussion started by: kristinu
13 Replies

6. Programming

Help in sorting and merging lists

Hi everyone, need your help in sorting and merging two numerical lists Example: I have one list 1 2 3 4 5 7 and the other 4 6 8, then the final output should be 1 2 3 4 5 6 7 8 Requesting your kind help in this Regards, RB :) (1 Reply)
Discussion started by: ramakanth_burra
1 Replies

7. Shell Programming and Scripting

Shell Script to Create non-duplicate lists from two lists

File_A contains Strings: a b c d File_B contains Strings: a c z Need to have script written in either sh or ksh. Derive resultant files (File_New_A and File_New_B) from lists File_A and File_B where string elements in File_New_A and File_New_B are listed below. Resultant... (7 Replies)
Discussion started by: mlv_99
7 Replies

8. Shell Programming and Scripting

List UID's between 100 and 200

If i wanted to list all users who have a UID between 100 and 200 which command would i use? (1 Reply)
Discussion started by: warlock129
1 Replies

9. UNIX for Advanced & Expert Users

help with sorting sequence in Unix C:sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list

Hi List is 000|2008-07-17|556543|RTJ|35-RTGJ|EYT 465|2008-11-10|567789|GHJ|45-DGHH|ETU 533|2008-09-06|567789|GHJ|45-DGHH|ETU How does it do it? sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list (6 Replies)
Discussion started by: gurvinder
6 Replies
Login or Register to Ask a Question