joを使ってファイル一覧のJSONをつくる
背景
友達から依頼されました。
サーバ関係でカレントディレクトリにある全ファイルを、拡張子ごとに分類したJSONをつくって欲しいとのことでした。
joを使います。
joのインストール
brew install jo
プログラム
for type in $(ls -F | grep -v / | grep -oE '\..*' | sort | uniq);do echo $type=$(ls *$type | awk '{print NR "=" $0}' | jo);done | jo -p
実行結果
Author And Source
この問題について(joを使ってファイル一覧のJSONをつくる), 我々は、より多くの情報をここで見つけました https://qiita.com/arabian9ts/items/41c5e7bff68d16def85c著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .