Last active
May 21, 2016 20:30
-
-
Save lancearlaus/4c35a17b2dadb3eb959d5ba9fa9dea76 to your computer and use it in GitHub Desktop.
Parse and sort file names using awk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Given the following list of files, sort by numeric index | |
# ls | |
# V10__allocate_utxo_function.sql | |
# V11__change_asset_ledger_id.sql | |
# V12__add_quantity_to_obligation.sql | |
# V13__allocate_sufficient_utxos_function.sql | |
# V14__add_spender_to_utxo.sql | |
# V15__drop_account_lookahead.sql | |
# V16__create_keychain.sql | |
# V1__create_asset_table.sql | |
# V2__create_obligation_table.sql | |
# V3__create_address_table.sql | |
# V4__create_account_table.sql | |
# V5__create_account_private_keys_table.sql | |
# V6__create_satoshi_address_table.sql | |
# V7__create_account_lookahead_table.sql | |
# V8__create_utxo_table.sql | |
# V9__add_asset_underlying.sql | |
ls | awk '{ match($0, /V([0-9]+)(.*)/, arr); printf("V%03d%s\t%s\n", arr[1], arr[2], arr[0]) }' | sort | cut -f2 | |
# V1__create_asset_table.sql | |
# V2__create_obligation_table.sql | |
# V3__create_address_table.sql | |
# V4__create_account_table.sql | |
# V5__create_account_private_keys_table.sql | |
# V6__create_satoshi_address_table.sql | |
# V7__create_account_lookahead_table.sql | |
# V8__create_utxo_table.sql | |
# V9__add_asset_underlying.sql | |
# V10__allocate_utxo_function.sql | |
# V11__change_asset_ledger_id.sql | |
# V12__add_quantity_to_obligation.sql | |
# V13__allocate_sufficient_utxos_function.sql | |
# V14__add_spender_to_utxo.sql | |
# V15__drop_account_lookahead.sql | |
# V16__create_keychain.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment