Use ed, cara!
ed -s poems <<< $'$-1\n'
Isto diz para abrir o arquivo poems
no modo de script ( -s
) (para que ele não imprima mensagens extras), então envia um comando de endereçamento em uma string here que diz "vá para o último linha do arquivo ( $
), menos 1 ", que imprime a linha.
Dado um arquivo de poema de entrada de :
A is for awk, which runs like a snail, and
B is for biff, which reads all your mail.
C is for cc, as hackers recall, while
D is for dd, the command that does all.
E is for emacs, which rebinds your keys, and
F is for fsck, which rebuilds your trees.
G is for grep, a clever detective, while
H is for halt, which may seem defective.
I is for indent, which rarely amuses, and
J is for join, which nobody uses.
K is for kill, which makes you the boss, while
L is for lex, which is missing from DOS.
M is for more, from which Less was begot, and
N is for nice, which it really is not.
O is for od, which prints out things nice, while
P is for passwd, which reads in strings twice.
Q is for quota, a Berkeley-type fable, and
R is for ranlib, for sorting ar sic table.
S is for spell, which attempts to belittle, while
T is for true, which does very little.
U is for uniq, which is used after Sort, and
V is for vi, which is hard to abort.
W is for whoami, which tells you your name, while
X is, well, X, of dubious fame.
Y is for yes, which makes an impression, and
Z is for zcat, which handles compression.
... a saída do resultado é:
Y is for yes, which makes an impression, and