~/ learn/ comp-325/ cards/ Putting a command’s input inside the script
1 of 9

The self-contained phone directory

The self-contained phone directory

Answer

#!/bin/sh grep -i "$1" << PHONES Ada Lovelace 403-555-0142 Grace Hopper 780-555-0199 Ken Thompson 604-555-0170 PHONES

The data is the standard input of grep. Nothing outside the script is opened, so there is no second file to ship or to lose.

S&K 3e ch13 §13.3; here-document rules from POSIX.1-2024 §2.7.4

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/451509a4-4a8f-4bf6-8d89-6b3e524ece6a/flashcard utf-8 LF