Skip to content

Instantly share code, notes, and snippets.

@musaprg
Created May 24, 2017 12:38
Show Gist options
  • Save musaprg/f16e282d059f155b662bf14a6388668a to your computer and use it in GitHub Desktop.
Save musaprg/f16e282d059f155b662bf14a6388668a to your computer and use it in GitHub Desktop.
一番新しいファイルを表示する
#!/bin/sh
# 古い演算結果が残ってたら削除
# -e で存在するか否かを返してくれる
if [ -e result.csv ]; then
rm result.csv
fi
# ls -t でタイムスタンプ順に新しいものからソートしてくれる
# set -- <hoge>でタブor空白ごとにsplitして$n(n=1,2,...)に格納してくれる
set -- `ls -t ./results`
echo $1
@musaprg
Copy link
Author

musaprg commented May 24, 2017

例えば演算結果をresultsディレクトリ内に格納しておいて,その中から最新のものを使って最終結果ファイルをresult.csvとして出力するときとかに使えるね!便利だねすごい!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment