Skip to content

Instantly share code, notes, and snippets.

@isann
Created June 20, 2012 09:00
Show Gist options
  • Save isann/2958925 to your computer and use it in GitHub Desktop.
Save isann/2958925 to your computer and use it in GitHub Desktop.
指定した名前に一致するパスを取得するBASH
RET=`ls /home/user/a_*dat` # a_ではじまりdatで終わるファイルの一覧
if [[ $? -ne 0 ]] # a_ではじまりdatで終わるファイルが1つもないと0以外の終了値になる
then
exit 9
else
for TXT in $RET # a_ではじまりdatで終わるファイルが1つ以上あったとき
do
echo ${TXT} # ファイルパスを出力する
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment