The << character is used to create a here document, which is a special type of redirection that reads input from the current source until a line containing only the delimiter (with no trailing blanks) is seen. The delimiter is specified after the << operator, and can be any string. For example, the following command will print everything between the << EOF and EOF lines:
cat << EOF This is a here document It can span multiple lines EOF
The output is:
This is a here document It can span multiple lines
The < character is used for normal input redirection, which reads data from a file or another command. The <| and !< characters are not valid redirection operators in Linux. The &< character is used to duplicate input file descriptors, which is an advanced topic not covered by the Linux Essentials exam. References:
[LPI Exam 101 Detailed Objectives], Topic 103: GNU and Unix Commands, Objective 103.4: Use streams, pipes and redirects, Weight: 4, Key Knowledge Areas: Redirecting standard input, standard output and standard error.
[LPI Linux Essentials Certification All-in-One Exam Guide], Chapter 5: Working with Files, Page 167, Using Here Documents.
QUESTIONNO: 16
Which of the following commands will NOT update the modify timestamp on the file /tmp/myfile.txt?
A. file /tmp/myfile.txt
B. echo "Hello" >/tmp/myfile.txt
C. sed -ie "s/1/2/" /tmp/myfile.txt
D. echo -n "Hello" >>/tmp/myfile.txt
E. touch/tmp/myfile.txt
Answer: A
The file command will not update the modify timestamp on the file /tmp/myfile.txt because it only reads the file content and determines its type. It does not write or change anything in the file.
The other commands will update the modify timestamp on the file /tmp/myfile.txt because they either overwrite the file content (B and C), append to the file content (D), or explicitly change the file timestamp (E).