Two audit copies in one pipeline

A script uses tee, a utility that copies its standard input to standard output and named files, to preserve two audit records:


Shell
printf '%s\n' oak pine oak elm | tee audit.txt | grep -v '^oak' | tee kept.txt | tr -d '\n' | wc -c


All commands succeed, both output files are writable, and each letter and newline occupies one byte. The printf command writes each supplied word on its own newline-terminated line. The grep stage rejects lines beginning with oak, and tr -d '\n' deletes newline characters.


A pipeline branches at two tee stages to create separate audit files.


Determine the number of lines in audit.txt, the number of bytes in kept.txt, and the byte count printed by wc -c. Enter each count as an exact integer with zero decimal places.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More The Shell Questions: