https://changelog.com/posts/bash-it-a-community-bash-framework
http://fahdshariff.blogspot.com/2017/05/shell-scripting-and.html
Examples:
2. <<
For example:
3. <<<
Examples:
http://fahdshariff.blogspot.com/2017/05/shell-scripting-and.html
<
allows you to pass data contained in a file to the standard input of a command. The format is:command < file |
# replace comma with new-lines: tr ',' '\n' < file # read a file line-by-line and do something with each line: while IFS= read -r line; do # do something with each line ssh "$line" who -b done < hosts.txt |
<<
allows you to pass multi-line text (called a here-document) to a command until a specific "token" word is reached. The format is:command << TOKEN line 1 line 2 TOKEN |
# query a database sqsh -S server -D db << END select * from table where foo= 'bar' go END |
<<<
allows you to pass a string of text (called a here-string) to a command. If you find yourself echo-ing text and piping it to a command, you should use a here-string instead. (See my previous post on Useless Use of Echo.) The format is:command <<< text |
tr ',' '\n' <<< "foo,bar,baz" grep "foo" <<< "foo,bar,baz" mailx -s subject $USER <<< "email body" |
|