LoginSignup
0
0

More than 5 years have passed since last update.

カレントディレクトリの新しいテキストを確認する

Posted at
# ignore more than 3 argument
echo ${1} | grep -P "\D" >> /dev/null \
    && files=3 \
    || files=${1:-3}
echo ${2} | grep -P "\D" >> /dev/null \
    && lines=10 \
    || lines=${2:-10}

head -n${lines} $(file $(ls -t)|grep text|head -n${files}|perl -pe 's/:[^:]*\n/ /')

バイナリを無視して新しいテキストの順番にheadで見れます。
ls -t でも最近のファイルは確認できるのですが、
その中身も見てみた方が想起しやすい場面で使います。

引数が無ければ3つの新しいテキストを10行、
1つ目の引数でファイル数を、2つ目の引数でそれぞれの表示する行数を指定できます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0