Deprecated: Array and string offset access syntax with curly braces is deprecated in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/inc/init.php on line 542
ja:bash:wanttodo4 [GiriWiki]

ユーザ用ツール

サイト用ツール


ja:bash:wanttodo4

連番ファイルの後半だけ削除

file_0.txt
file_1.txt



file_99.txt
があるうち、50−99までを削除したいとする。

ls -v file_* | tail -n 50 | xargs rm

  • ls -v file_* で数字順にls出力
  • | tail -n 50で前の出力の後ろ50を切り出す
  • | xargs rmで前の出力をパラメータとして受け取り、rmに渡している

はじめ、lsがaliasされてうまくいかなかったが“\ls”としてやるとうまくいった。

ja/bash/wanttodo4.txt · 最終更新: 2017/08/30 04:10 by kota