tail 使います
こんな状況だとします
$ ls -l
total 72
-rw-r--r-- 1 mochizuki staff 14 2 25 16:04 hoge1.rb
-rw-r--r-- 1 mochizuki staff 17 2 25 16:05 hoge2.rb
-rw-r--r-- 1 mochizuki staff 20 2 25 16:05 hoge3.rb
-rw-r--r-- 1 mochizuki staff 27 2 25 16:06 hoge4.rb
-rw-r--r-- 1 mochizuki staff 73 2 25 17:00 omake.js
-rw-r--r-- 1 mochizuki staff 25 2 25 16:37 piyo1.js
-rw-r--r-- 1 mochizuki staff 28 2 25 16:39 piyo2.js
-rw-r--r-- 1 mochizuki staff 31 2 25 16:40 piyo3.js
-rw-r--r-- 1 mochizuki staff 38 2 25 16:40 piyo4.js
ここから、たとえば、hoge${i}
の中身を全部眺めるとします。
こんな仕上がりです
$ tail -n +1 hoge*
==> hoge1.rb <==
a = 1 + 2
p a
==> hoge2.rb <==
a = 1
+ 2
p a
==> hoge3.rb <==
a =
1
+ 2
p a
==> hoge4.rb <==
a
=
1
+ 2
p a
tail のマニュアル
-n +1
はファイルの1行目から表示するというオプションです。
man tail
を叩いて、マニュアルをよみます。
マニュアルの抜粋
DESCRIPTION
The tail utility displays the contents of file or, by default, its standard input, to the standard output.
The display begins at a byte, line or 512-byte block location in the input. Numbers having a leading plus (`+') sign are
relative to the beginning of the input, for example, ``-c +2'' starts the display at the second byte of the input. Num-
bers having a leading minus (`-') sign or no explicit sign are relative to the end of the input, for example, ``-n 2''
displays the last two lines of the input. The default starting location is ``-n 10'', or the last 10 lines of the input.
以上ありがとうございます。