#!/bin/bash
s='This is the first sample line 1
this is the second sample line
another line
total lines: 3 tot'
awk '/^total lines:/{print $3; exit}' <<< "$s"
IyEvYmluL2Jhc2gKcz0nVGhpcyBpcyB0aGUgZmlyc3Qgc2FtcGxlIGxpbmUgMQp0aGlzIGlzIHRoZSBzZWNvbmQgc2FtcGxlIGxpbmUKYW5vdGhlciBsaW5lCgp0b3RhbCBsaW5lczogMyB0b3QnCgphd2sgJy9edG90YWwgbGluZXM6L3twcmludCAkMzsgZXhpdH0nIDw8PCAiJHMi