日々精進

新しく学んだことを書き留めていきます

スペースを含むファイル名をpecoで選択する

ファイル、フォルダなどの名前をpecoで選択する場合、以下のようにするとファイル名などにスペースが入っていると正しく選択出来ない。

ls -l | peco | awk '{ print $9 }'

以下のようにfindを使うと切り出す必要が無いのでこちらの方が良い。

find . -maxdepth 1 | peco

参考:bash - awk '{print $9}' the last ls -l column including any spaces in the file name - Stack Overflow