Skip to content

Instantly share code, notes, and snippets.

@Buravo46
Last active March 11, 2017 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Buravo46/e0028f890757fe38e6cd10ffd9dc9fae to your computer and use it in GitHub Desktop.
Save Buravo46/e0028f890757fe38e6cd10ffd9dc9fae to your computer and use it in GitHub Desktop.
【Shell】指定したディレクトリ配下のファイル名を取得

findコマンドでファイルパスの一覧を取得し、for文で回す。

#! /bin/bash

list=`find ${1} -type f -name ${2}`
for item in ${list[@]}
do
  echo "FILEPATH: "${item}
  echo "FILENAME: "`basename ${item}`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment