Definition Umleitung <<< gelöst

Post Reply
Message
Author
sumsi
Posts: 21
Joined: 18. Dec 2018 8:56

Definition Umleitung <<< gelöst

#1 Post by sumsi »

Hallo Leute,

wie ist die genaue Funktionsweise bzw. Definition von drei Umlenk-Zeichen?

Folgendes ist zwar selbsterklärend, ich könnte es einfach so hinnehmen, bc -l <<< '1/3', aber es stört mich, dass ich dieses Konstrukt nicht kenne.
Geht das in irgendeiner Konstruktion auch in die andere Richtung?
Last edited by sumsi on 21. Nov 2019 9:51, edited 1 time in total.

User avatar
hjb
Pro-Linux
Posts: 3264
Joined: 15. Aug 1999 16:59
Location: Bruchsal
Contact:

Re: Definition Umleitung <<<

#2 Post by hjb »

Hi,

mir war das Konstrukt auch nicht geläufig. Hier ist die Erklärung in der Bash-Manpage:

Code: Select all

   Here Strings
       A variant of here documents, the format is:

              [n]<<<word

       The  word  undergoes  tilde  expansion,  parameter  and variable expansion, command substitution, arithmetic expansion, and quote removal.
       Pathname expansion and word splitting are not performed.  The result is supplied as a single string, with a newline appended, to the  com‐
       mand on its standard input (or file descriptor n if n is specified).
Damit ist

Code: Select all

bc -l <<< '1/3'
dasselbe wie

Code: Select all

echo '1/3' | bc -
Für mich sieht es so aus, als sei <<< komplett redundant. Eine Umkehrung kann es prinzipiell nicht geben.

Grüße,
hjb
Pro-Linux - warum durch Fenster steigen, wenn es eine Tür gibt?

sumsi
Posts: 21
Joined: 18. Dec 2018 8:56

Re: Definition Umleitung <<< gelöst

#3 Post by sumsi »

OK, danke. Ein HERE-Document ohne EOF-Konstruktion.
Ich in meiner Ausbildung nur bis 2 Umlenk-Zeichen gekommen ....

Viele Grüße
sumis

Post Reply