Skip to content

Instantly share code, notes, and snippets.

@yatt
Created January 19, 2012 16:16
Show Gist options
  • Select an option

  • Save yatt/1640900 to your computer and use it in GitHub Desktop.

Select an option

Save yatt/1640900 to your computer and use it in GitHub Desktop.
sort filenames with number (not aligned)
#!/bin/sh
# 桁揃えされていないファイル(ex. 1.jpg,...,10.jpg,...etc)
# を数値順に表示する。
#
/bin/ls -1 $1 \
| tee /tmp/ls.txt \
| egrep -o '[0-9]+' \
| awk '{printf("%010d\n",$_)}' \
| paste - /tmp/ls.txt \
| sort -k1 \
| cut -f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment