Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to sort files in directory numerically? Post 303043476 by RudiC on Wednesday 29th of January 2020 11:37:13 AM
Old 01-29-2020
I find your approach working. Could be somewhat simplified, like
Code:
ls  back* | sort -tk -k3n
backup.bk1
backup.bk2
backup.bk3
backup.bk100
backup.bk200
backup.bk300


With your -l option to ls, which outputs user and group of the file - is it possible those files' have a k in either of the two fields?
 

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
nisbackup(1M)						  System Administration Commands					     nisbackup(1M)

NAME
nisbackup - backup NIS+ directories SYNOPSIS
nisbackup [-v] backup-dir directory... nisbackup [-v] -a backup-dir DESCRIPTION
nisbackup backs up a NIS+ directory object on a NIS+ master server. Updates to the NIS+ database will be temporarily disabled while nis- backup is running. The backup-dir is a UNIX directory that must exist prior to running nisbackup. The nisbackup command can be used to backup an individual NIS+ directory object or all ( -a) of the NIS+ directory objects served by a master server. The NIS+ directory objects being backed up will be placed into subdirectories under the backup-dir directory. These subdirectories are named according to the NIS+ directory object they contain. nisbackup operates on individual NIS+ directory objects (for example, org_dir.wiz.com). This allows an administrator to selectively backup specific directories. The rpc.nisd(1M) process must be running on the master server with a stable NIS+ database for nisbackup to complete. nisbackup will not attempt to correct any corruption in the NIS+ database, so it is important that backups be done regularly as part of the NIS+ administra- tion. The first synopsis is used to backup a single NIS+ directory object or a list of NIS+ directory objects. The objects can be partially qual- ified or fully qualified. The machine on which the command is executing must be the master for the NIS+ directory objects specified. The second synopsis will backup all of the NIS+ directory objects that are served by this master. The -a option is the recommended method of backing up a master server, since it will backup all NIS+ directory objects that are served by this master. If this server is a master server for more than one domain, the backup will include NIS+ directories that belong to all of the domains served. Individual NIS+ direc- tory objects can be selected for restoring from a backup-dir created with the -a option. See nisrestore(1M). The -a option only includes directory objects for which this server is the master. It is possible, but not recommended, to configure a master server as a replica for other domains. The objects belonging to those replicated domains will not be backed up with the -a option. The backup of replicated objects must be run on the master server for those objects. Do not use the same backup-dir to backup different master servers. Each master server must have its own backup-dir. nisbackup will set the rpc.nisd(1M) to read only mode, which will disable updates to the NIS+ database. This is neccessary to ensure the consistency of the backup. For this reason, nisbackup should not be run while large numbers of updates are being applied to the NIS+ data- base. Update utilities such as nisaddent(1M) should not be run simultaneously with nisbackup. OPTIONS
-a Creates a backup of all NIS+ directory objects for which this server is a master. -v Verbose option. Additional output will be produced and sent to syslog(3C) upon execution of the command (see syslog.conf(4)). OPERANDS
backup-dir The directory into which the subdirectories containing the backed up objects are placed. This must be created prior to running nisbackup. directory The NIS+ directory object(s) being backed up. EXAMPLES
Example 1: Backup of the org_dir NIS+ directory object of the domain foo.com on a master server to a directory named /backup To backup the org_dir NIS+ directory object of the domain foo.com on a master server to a directory named /backup: master_server# nisbackup /backup org_dir.foo.com. Example 2: Backup of the entire NIS+ domain foo.com to a directory named /backup To backup the entire NIS+ domain foo.com to a directory named /backup: master_server# nisbackup /backup foo.com. org_dir.foo.com. groups_dir.foo.com. ctx_dir.foo.com. Example 3: Backup of an entire NIS+ database to a backup directory named /backup To backup an entire NIS+ database to a backup directory named /backup: master_server# nisbackup -a /backup EXIT STATUS
0 Successful completion. 1 An error occurred. FILES
/backup-dir/backup_list This ascii file contains a list of all the objects contained in this backup-dir directory. /backup-dir/directory-object A subdirectory that is created in the backup-dir that contains the NIS+ directory-object backup. /backup-dir/directory-object/data A subdirectory that contains the data files that are part of the NIS+ directory-object backup. /backup-dir/directory-object/last.upd This data file contains timestamp information about the directory-object. /backup-dir/directory-object/data.dict A NIS+ data dictionary for all of the objects contained in the NIS+ directory-object backup. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWnisu | +-----------------------------+-----------------------------+ SEE ALSO
nis+(1), nisdefaults(1), nisrm(1), nisrestore(1M), rpc.nisd(1M), syslog(3C), nisfiles(4), syslog.conf(4), attributes(5) NOTES
NIS+ might not be supported in future releases of the SolarisTM Operating Environment. Tools to aid the migration from NIS+ to LDAP are available in the Solaris 9 operating environment. For more information, visit http://www.sun.com/directory/nisplus/transition.html. SunOS 5.10 12 Dec 2001 nisbackup(1M)
All times are GMT -4. The time now is 04:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy