Home
Back To Top
Home
Using
HERE-STRING Here the <<< is a here-string, which lets you pass strings
directly to the standard input of commands.
# read _ read_sec _ _ read_five _ <<<
"$string"
# echo $read_sec
# echo $read_five
Split a
string on a given character
# string="rose-merry-john-rambo"
# read -r -d - x y z <<< "$string"
# echo $x
# echo $y
# echo $z
To redirect
list of strings i.e. multiline to the standard input of a command
# command <<EOL
One
Two
Three
Four
EOL
# sed 's|http://||' <<EOL
http://url1.com
http://url2.com
http://url3.com
EOL
To redirect
a single line of text to the standard input of a command
# command <<< "One Two Three"
# echo "Four Five Six" | command
Home
No comments:
Post a Comment