shelllings

a practical way to learn shell
git clone https://git.davidvoz.net/shelllings.git
index
logs
tree
license

08_cat.sh
1#!/bin/sh
2
3# We briefly mentioned the cat command earlier. It prints out all the
4# data of a file into the terminal. And like the animal, 2 more commands
5# are used. Head to print out the first lines of a file and tail to
6# print out the last lines of a file.
7#
8# $ cat file # prints out the entiretly of a file
9# $ head file # prints out the first 10 lines of a file
10# $ tail file # prints out the last 10 lines of a file
11# $ head -n 1 # prints out only the first line of a file
12# $ tail -n 18 # prints out only the last 18 lines of a file
13# $ head -n -4 # prints out all lines except the last 4 lines
14# $ tail -n +9 # prints out from line 9, onwards
15#
16# Fix the command below to do a word count on the last 50 lines of the
17# LICENSE file in this repository. Don't change the new file name.
18
19head 50 LICENSE > 08_cat # the '>' sign is discussed later. For now
20# know that the command should be outputting
21# the last 50 lines into a file called 08_cat
22wc -l 08_cat