Thursday, October 11, 2007

Display a Specified Number of Lines From Multiple Files

Here's an ad-hoc way of viewing a specified number of lines that begins with line one. In this example, the templated report has 8 lines and only its values change each day.

I only want to show the first 5 lines for each file. Here's a quick and dirty way of doing that.

In this template file (Mon), the values are only shown for illustration purposes .

# cat Mon
Average Stats: 100
Hourly Stats: 4
Daily Stats: 103
Weekly Stats: 700
Monthly Stats: 2812
###############
END END
###############

Display 5 different files and show their first 5 lines
# head -5 Mon Tue Wed Thu Fri
==> Mon <==
Average Stats: 100
Hourly Stats: 4
Daily Stats: 103
Weekly Stats: 700
Monthly Stats: 2812

==> Tue <==
Average Stats: 102
Hourly Stats: 4
Daily Stats: 104
Weekly Stats: 706
Monthly Stats: 2822

==> Wed <==
Average Stats: 104
Hourly Stats: 5
Daily Stats: 110
Weekly Stats: 730
Monthly Stats: 2842

==> Thu <==
Average Stats: 90
Hourly Stats: 200
Daily Stats: 2400
Weekly Stats: 4499
Monthly Stats: 3006

==> Fri <==
Average Stats: 101
Hourly Stats: 3
Daily Stats: 106
Weekly Stats: 703
Monthly Stats: 2855

Here's a poor man's label maker. Cut (literally) and paste :)
# cat > From
FirstName LastName
123 Any Street
Anytown, State, Zipcode
Ctrl+d

# head From From From
==> From <==
FirstName LastName
123 Any Street
Anytown, State, Zipcode

==> From <==
FirstName LastName
123 Any Street
Anytown, State, Zipcode

==> From <==
FirstName LastName
123 Any Street
Anytown, State, Zipcode

No comments: