macでインフォマティクス

macでインフォマティクス

HTS (NGS) 関連のインフォマティクス情報についてまとめています。

lsのモダンな代替コマンド exa

2020 6/1 誤字修正, 文章修正

 

lsが45年以上続いている今、exaは1970年代とは異なる仮定の下で開発することができる。コンピュータはもはやボトルネックではない。1970年代にUnixを開発していた開発者はテレタイプを使ってUnixとやりとりしていただろう。キーボードとプリンタを備えたマシンで、Unixコンピュータとリモートで通信できるようになっていたのである。オペレーティングシステムの短いコマンド名はこれを反映していた。より高速なコンピュータ、ディスクドライブ、ネットワーク接続のおかげで、より多くの情報を表示することは、その情報が送られてくるのを待つために数秒の余分な時間を費やすよりも、ほとんどの場合、望ましいことである。

 exa は、UnixLinux オペレーティングシステムに搭載されているコマンドラインプログラム ls の最新版で、より多くの機能とより良いデフォルトを備えている。exa は複数の色を使ってファイルの種類やメタデータを区別し、シンボリックリンク、拡張属性、Git を認識できる。このコマンドは、ターミナルユーザ、管理者、開発者によって毎日何百回も使用されており、自動化されたスクリプトを書くときにも便利である。

  

 

HP

https://the.exa.website/#installation

 

インストール 

mac os10.14に導入した。

#Rustがないなら先に導入(HP

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

#~/.cargo/binにパスを通す。ここでは.bashrcに書き込む。
echo 'export PATH=$PATH:~/.cargo/bin' >> ~/.bashrc && source ~/.bashrc

 

本体 Github

 cargoを使ってexaを導入

#cargo
cargo install exa

#またはhomebrewを使う
brew install exa

exa --help

$ exa --help

Usage:

  exa [options] [files...]

 

  -?, --help         show list of command-line options

  -v, --version      show version of exa

 

DISPLAY OPTIONS

  -1, --oneline      display one entry per line

  -l, --long         display extended file metadata as a table

  -G, --grid         display entries as a grid (default)

  -x, --across       sort the grid across, rather than downwards

  -R, --recurse      recurse into directories

  -T, --tree         recurse into directories as a tree

  -F, --classify     display type indicator by file names

  --colo[u]r=WHEN    when to use terminal colours (always, auto, never)

  --colo[u]r-scale   highlight levels of file sizes distinctly

 

FILTERING AND SORTING OPTIONS

  -a, --all                  show hidden and 'dot' files

  -d, --list-dirs            list directories like regular files

  -L, --level DEPTH          limit the depth of recursion

  -r, --reverse              reverse the sort order

  -s, --sort SORT_FIELD      which field to sort by

  --group-directories-first  list directories before other files

  -D, --only-dirs            list only directories

  -I, --ignore-glob GLOBS    glob patterns (pipe-separated) of files to ignore

  --git-ignore               Ignore files mentioned in '.gitignore'

  Valid sort fields:         name, Name, extension, Extension, size, type,

                             modified, accessed, created, inode, and none.

                             date, time, old, and new all refer to modified.

 

LONG VIEW OPTIONS

  -b, --binary       list file sizes with binary prefixes

  -B, --bytes        list file sizes in bytes, without any prefixes

  -g, --group        list each file's group

  -h, --header       add a header row to each column

  -H, --links        list each file's number of hard links

  -i, --inode        list each file's inode number

  -m, --modified     use the modified timestamp field

  -S, --blocks       show number of file system blocks

  -t, --time FIELD   which timestamp field to list (modified, accessed, created)

  -u, --accessed     use the accessed timestamp field

  -U, --created      use the created timestamp field

  --time-style       how to format timestamps (default, iso, long-iso, full-iso)

  --git              list each file's Git status, if tracked or ignored

  -@, --extended     list each file's extended attributes and sizes

 

 

 ラン 

exa -l

m$ exa -l

drwxr-xr-x     - kazuma 17 4  8:47  1

.rw-r--r--@ 4.0M kazuma 12 2 22:06  1.fasta

.rw-r--r--   233 kazuma 17 2  9:09  1.fasta.fai

.rw-r--r--@ 1.7M kazuma 15 4 20:57  2.vcf

 

exa -abghHliS
  • -a     show hidden and 'dot' files
  • -b     list file sizes with binary prefixes
  • -g     list each file's group
  • -h      add a header row to each column
  • -H     list each file's number of hard links
  • -l       display extended file metadata as a table
  • -i       list each file's inode number
  • -S     show number of file system blocks

$ exa -abghHliS

   inode Permissions Links  Size Blocks User   Group Date Modified Name

27894801 .rw-r--r--      1    54      8 kazuma staff 11 2 20:19    .auspp.info

31770299 .rw-r--r--@     1   762     16 kazuma staff 16 4 19:57    data.tsv

31771461 .rw-r--r--@     1   762     16 kazuma staff 16 4 19:57    data.txt

28464421 drwxr-xr-x      3     -      - kazuma staff 17 2  9:09    null

31755117 drwxr-xr-x      2     -      - kazuma staff 15 4 20:59    output_dir

29326256 .rw-r--r--      1  88Mi 181384 kazuma staff  5 3 21:28    paired_1.aln

29326255 .rw-r--r--      1  83Mi 170920 kazuma staff  5 3 21:28    paired_1.fq

29326258 .rw-r--r--      1  87Mi 180256 kazuma staff  5 3 21:28    paired_2.aln

29326257 .rw-r--r--      1  83Mi 170976 kazuma staff  5 3 21:28    paired_2.fq

 

引用

GitHub - ogham/exa: A modern version of ‘ls’.

 

参考


追記

コードのシンタックスハイライトに対応したcatであるbatも導入してみる。

cargo install bat

 ラン

bat input_file

 大きなファイルは自動でlessコマンドに渡されてページ表示される。

f:id:kazumaxneo:20200531230541p:plain