Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to sort files in directory numerically? Post 303043475 by c3rb3rus on Wednesday 29th of January 2020 11:25:53 AM
Old 01-29-2020
Yes I tried using this..

Code:
ls -l /usr1/tmp/backup.bk* | sort -tk -k 3.1b,3n

But it does not give the desired results, I am reading through the sort manual but it is very confusing.
 

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
PG_STAGING(1)							  [FIXME: manual]						     PG_STAGING(1)

NAME
pg_staging - Prepare a staging environment from http accessible backups SYNOPSIS
pg_staging [--version] [-c configuration file] [-t tmpdir] [-d debug] [-v verbose] [-q quiet] <command> <dbname> [<date>] DESCRIPTION
pg_staging is a tool to prepare and maintain a staging environment from http accessible backups. Its main job (see command restore) is to: 1. create target database, named dbname_YYYYMMDD 2. add this database to the pgbouncer setup, reload pgbouncer 3. fetch a backup file named dbname.date -I.dump 4. prepare a filtered catalog for the given dump, depending on configuration 5. given sql_path and a pre directory, psql -f *.sql in there 6. pg_restore the backup with the custom catalog to the created database 7. if restore_vacuum is true, VACUUM ANALYZE the database 8. given sql_path setup and a post directory, psql -f *.sql in there 9. switch pgbouncer entry for dbname to target dbname_YYYYMMDD and reload pgbouncer again. pg_staging is able to do some more, mainly the commands given allow to give fine grain control over what it does rather than only providing the full restore option. DEPENDENCIES
pg_staging will use the following external tools: o pgbouncer in order to maintain more than one staging database o pg_restore which major version must match target database cluster o scp to upload new pgbouncer.ini configuration files o ssh to run the staging-client.sh on the target host See next section for how to prepare those components. INITIAL SETUP
In order for pg_staging to be able to manage any target you give it, the following conditions have to be met: 1. install staging-client.sh on the target host Currently you have to ssh non interactively (setup a password free ssh key authentication) to the target host. pg_staging will run the following command: ssh <host> sudo ./staging-client.sh <pgbouncer.xxxx.ini> <pgbouncer_port> 2. install and open pgbouncer "trust" connection as maintenance user (dbuser) on the maintenance database (maintdb). This connection will get used to CREATE DATABASE and DROP DATABASE. COMMANDS
commands This will show available commands and a docstring for each. main operation init <dbname> Prepare a cluster given a pg_dumpall -g file, see option dumpall_url. dump <dbname> [<filename>] dump given database to file, using pg_dump in custom format. The pgbouncer_port is used and the filename defaults to dbname.YYYYMMDD.dump. The pg_restore directory part is considered for finding the pg_dump binary. This command will prevent you from overwriting an existing dump file, see redump if you do not want this behavior. redump <dbname> [<filename>] dump even when destination filename already exists. restore <dbname> [<YYYYMMDD>] See description section, it explains the details. It may be of importance to recall that restore will clean up its temporary files, including the dump file itself. The clean up happens in case of success and in case of error. This command will source pre and post sql files, as per sql_path config. drop <dbname> [<YYYYMMDD>] DROP DATABASE the given database, or today's one if none given. It won't edit pgbouncer configuration accordingly though, as of version 0.5. switch <dbname> [<YYYYMMDD>] Change the canonical <dbname> entry in pgbouncer to point to given dated instance, default to today's one. purge <dbname> Clean the database section by dropping out the older databases and keeping online only the keep_bases most recent. vacuumdb <dbname> [<YYYYMMDD>] VACUUM ANALYZE given database. load <dbname> <filename> pg_restore given dump file, this allow to skip the auto downloading part of the restore command. fetch <dbname> [<YYYYMMDD>] Only fetch the dump, do not restore it, do not remove it afterwards. presql <dbname> [<YYYYMMDD>] Source the sql_path/pre/*.sql files into the database by means of psql -f, in alphabetical order, without recursive walking into subdirs. postsql <dbname> [<YYYYMMDD>] Source the sql_path/post/*.sql files into the database by means of psql -f, in alphabetical order, without recursive walking into subdirs. listings databases Show the list of database sections parsed into the .ini file. backups <dbname> [<YYYYMMDD>] Show <dbname> available backups on the http host. dbsize <dbname> [<YYYMMDD>] Show database size of given instance, as returned by SELECT pg_size_pretty(pg_database_size(dbname_YYYYMMDD)); dbsizes --all | --match <pattern> | <dbname> Show database sizes of given instances. With --all show sizes of all instances of all configured section, with --match you can reduce the listing to regexp matching section names, with a <dbname> it'll show sizes of all instances of given section. show <dbname> [<YYYYMMDD>] <setting> Show current value of <setting> for given database. pgbouncer pgbouncer <dbname> Show pgbouncer database listing for given dbname. pause <dbname> [<YYYMMDD>] Issue a pgbouncer pause <dbname> command. resume <dbname> [<YYYMMDD>] Issue a pgbouncer resume <dbname> command. londiste londiste <dbname> [<YYYMMDD>] Prepare londiste configuration files in TMPDIR, then send them over to the provider hosts in ~pgstating/londiste and start the daemons (pgqadm.py and londiste.py). remote service management Note that all actions (start, stop, restart, status) are not available to all services (londiste, ticker, pgbouncer). start <service> <dbname> [<YYYMMDD>] Start remote service for given dbname, where service is one of londiste, ticker, or pgbouncer. stop <service> <dbname> [<YYYMMDD>] Stop remote service for given dbname, where service is one of londiste, ticker, or pgbouncer. restart <service> <dbname> [<YYYMMDD>] Restart remote service for given dbname, where service is one of londiste, ticker, or pgbouncer. status <service> <dbname> [<YYYMMDD>] Show status remote service for given dbname, where service is one of londiste, ticker, or pgbouncer. experimental and internal nodata Show tables we want to skip loading DATA for, those we are a subscriber of. catalog Show the filtered out catalog we'll give to pg_restore -L. triggers Show the schema-qualified functions used by triggers, in order to be able to follow dependancies when filtering out a schema definition (such as pgq or londiste). OPTIONS
Usage: pg_staging.py [-c <config_filename>] command dbname <args> Options: -h, --help show this help message and exit --version show pg_staging version -c CONFIG, --config=CONFIG configuration file, defauts to /etc/hm- tools/pg_staging.ini -n, --dry-run simulate operations, don't do them -v, --verbose be verbose and about processing progress -q, --quiet be terse, almost silent -d, --debug provide python stacktrace when error -t TMPDIR, --tmpdir=TMPDIR temp dir where to fetch dumps, /tmp CONSOLE
If you start pg_staging without command, it will open up an interactive console with basic readline support. All previous commands are supported, except for the experimental ones, and the following are added. config <filename> read given filename as the current configuration file for pg_staging. set <section> <option> <value> set given option to given value for current interactive session only. get <section> <option> print current value of given option. verbose switch on and off the verbosity of pg_staging. INTERNALS
How we use tools. Will get expanded if questions arise. SEE ALSO
pg_staging(5) AUTHOR
pg_staging is written by Dimitri Fontaine <dim@tapoueh.org[1]>. NOTES
1. dim@tapoueh.org mailto:dim@tapoueh.org [FIXME: source] 11/24/2009 PG_STAGING(1)
All times are GMT -4. The time now is 02:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy