Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to sort files in directory numerically? Post 303043470 by c3rb3rus on Wednesday 29th of January 2020 10:40:06 AM
Old 01-29-2020
How to sort files in directory numerically?

Trying to sort a bunch of files numerically but can't seem to get the command just right. This is in a IBM AIX machine.

I have a directory that has...
Code:
backup.bk1
backup.bk100
backup.bk2
backup.bk200
backup.bk3
backup.bk300

There are a lot more files but this is shortened for the example.

If I simply do a ls -l on the directory I get..
Code:
backup.bk1
backup.bk100
backup.bk2
backup.bk200
backup.bk3
backup.bk300

I need the list to include the full directory path (in this case the files are stored in /usr1/temp) and the file name like this..
Code:
/usr1/temp/backup.bk1
/usr1/temp/backup.bk2
/usr1/temp/backup.bk3
/usr1/temp/backup.bk100
/usr1/temp/backup.bk200
/usr1/temp/backup.bk300

Anyone able to help me out?

Moderator's Comments:
Mod Comment
Please use code tags, as required by forum rules.
Thanks!

Last edited by Peasant; 01-29-2020 at 11:45 AM.. Reason: Added code tags.
 

10 More Discussions You Might Find Interesting

1. AIX

loop through the directory for files and sort by date and process the first file

hello i have a requirement where i have a direcotry in which i get files in the format STOCKS.20080114.dat STOCKS.20080115.dat STOCKS.20080117.dat STOCKS.20080118.dat i need to loop through the directory and sort by create date descending order and i need to process the first file. ... (1 Reply)
Discussion started by: dsdev_123
1 Replies

2. UNIX for Dummies Questions & Answers

Sort all files in a directory retaining originals

Hi, I need to sort all the files in a directory whilst retaining the originals. So if in the directory I have: File1 File2 File3 I want to sort these files so that I would have: File1 File1.sort File2 File2.sort File3 File3.sort where I have added the .sort extension to show... (4 Replies)
Discussion started by: ledgie
4 Replies

3. UNIX for Dummies Questions & Answers

Sort file alphabetically AND numerically

Hi all. I have 2 files like this: f1 A 10 B 80 C 9 f2 A 11 B 700 C 10 What I want is the concatenation of the two files sorted by name (alphabetically) and size (numerically), so the result should be like this: F3 (cat f1 f2 sorted) A 10 A 11 B 80 B 700 (2 Replies)
Discussion started by: mrodrig
2 Replies

4. Shell Programming and Scripting

How to sort a set of files by date in a directory?

hi there, I have a directory which contents I can parse dynamically. I end up with a file list. I then want to display those files sorted by date, oldest files first. I have very very little PERL experience...Would anyone know how to do that ? Thanks in advance. (8 Replies)
Discussion started by: alexf
8 Replies

5. Shell Programming and Scripting

Numerically sort problem for a long list of file name

I got a long list of file name. My input: data_1.txt data_2.txt data_3.txt data_10.txt data_21.txt data_12.txt data_4.txt My desired output: data_1.txt data_2.txt data_3.txt data_4.txt data_10.txt data_12.txt data_21.txt Does anybody got idea how to archive it? (11 Replies)
Discussion started by: patrick87
11 Replies

6. UNIX for Dummies Questions & Answers

Sort 2 columns numerically

Hi, A basic query. In the example file below, I want to sort by column 1 and then by column 2 numerically. I have tried sort -k2n,1 file1 but while this sorts the columns in the correct order, it does not sort column 2 numerically. Any help would be much appreciated. Also, if you have time to... (3 Replies)
Discussion started by: auburn
3 Replies

7. Shell Programming and Scripting

Sort numerically a non numerical

Hello, I have this sample data: 01 * * * * 01 * * * * 01 * * * * 01 * * * * 01 0 * * * 01 0 * * * 01 0 * * * 01 0 * * * 02 * * * 0 02 * * * 0 02 * * * 6 02 * * * 6 02 0 * * 1 02 0 * * 1 02 0 * * 2 02 0 * * 2 02 0 * * 3 (3 Replies)
Discussion started by: gio001
3 Replies

8. Shell Programming and Scripting

Sort alphabetically, then numerically

Greetings - I'm not necessarily new to bash scripting - I'm probably between beginner and intermediate, but I have something that I just cannot figure out after many attempts to find it. I have a file that is merely a list of many files, with their respective paths, and a branch path (ClearCase)... (5 Replies)
Discussion started by: 1cor29
5 Replies

9. UNIX for Dummies Questions & Answers

Redirecting tmp files of SORT into different directory

Hey Guys, I am facing an annoying scenario, fewer times when I execute the sort command, it throws out on error saying that "No Space on available on /var/tmp/<temp file name>. May be it is set to /var/tmp directory. I was wondering, if I cant redirect the temporary file creation to any other... (3 Replies)
Discussion started by: abhisheksunkari
3 Replies

10. UNIX for Dummies Questions & Answers

[Solved] Reverse the order of a list of file names (but not sort them alphabetically or numerically)

Hello all, I have a list of file names in a text document where each file name consists of 4 letters and 3 numbers (for example MACR119). There are 48 file names in the document (they are not in alphabetical or numerical order). I would like to reorder the list of names so that the 48th name is... (3 Replies)
Discussion started by: MDeBiasse
3 Replies
BIORUBY(1)						      General Commands Manual							BIORUBY(1)

NAME
br_bioflat.rb -- OBDA flat file indexer SYNOPSIS
Search: br_bioflat.rb [--search] [options...] br_bioflat.rb [--search] [--location DIR] [--dbname DBNAME] [options...] [KEYWORDS] Create index: br_bioflat.rb [--create] [--location DIR] [--dbname DBNAME] [--format genbank|embl|fasta] [options...] [--files FILES...] Update index: br_bioflat.rb [--update] [--location DIR] [--dbname DBNAME] [options...] [--files FILES...] Show namespaces: br_bioflat.rb [--show-namespaces] [--location DIR] [--dbname DBNAME] [DIR/DBNAME] br_bioflat.rb [--show-namespaces] [--format=CLASS] br_bioflat.rb [--show-namespaces] [--files file] DESCRIPTION
This manual page documents briefly the br_bioflat.rb. br_bioflat.rb is an OBDA flat file indexer. OPTIONS
--search Search a database for keywords. --namespace --name Only valid with the --search option. Set the search namespace. You can set this option multiple times to specify more than one namespace. --create Create an index. --location Specify the directory. --dbname Specify the name of the database. --primary --secondary Set the primary and secondarynamespace of the index. Default primary/secondary namespaces depend on the format of the flatfiles. Only valid with the --create option. --add-secondary Add secondary namespaces to the default specification. You can use this option many times. Only valid with the --create option. --update Update an index --sort Sort an index. You can set this to a path to an external sorting program, or BUILTIN to use the builtin sort module. This option is only valid with --create (or --update) and --type flat options. --renew Re-read all flatfiles and update whole index. This option is only valid with the --update option. --show-namespaces Display the namespaces for an index file. AUTHOR
This manual page was written by David Nusinow dnusinow@debian.org for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. BIORUBY(1)
All times are GMT -4. The time now is 04:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy