...

/

Script for Managing the Contacts

Script for Managing the Contacts

Learn how the read command can process files.

Using read

Let’s consider that contacts.txt contains the following content.

Alice=alice@gmail.com
Bob=(697) 955-5984
Eve=(245) 317-0117
Mallory=mallory@hotmail.com

Here is an example to read the first line of the contacts.txt file. The following command does it:

read -r contact < contacts.txt

This command writes the Alice=alice@gmail.com string to the contact variable.

We can write ...