[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [linux] bash et variables
c'est ce que je comptais faire mais je me demandais si y'avait pas un
autre moyen!
Si, tu peux faire ça avec <<EOF, sans problème.
L'astuce est simplement qu'il y a une différence entre
cat<<EOF
...
EOF
et
cat<<'EOF'
...
EOF
(et apparamment aussi "EOF")
Un exemple:
x=100
cat<<EOF
y=$x
EOF
=> donne: y=100
x=100
cat<<"EOF"
y=$x
EOF
=> donne y=$x
(ce serait pareil avec cat<<'EOF')
Extrait de man bash (section "here documents"):
The format of here-documents is as follows:
<<[-]word
here-document
delimiter
[...]
No parameter expansion, command substitution, arithmetic expansion, or pathname expansion is
performed on word. If any characters in word are quoted, the delimiter is the result of
quote removal on word, and the lines in the here-document are not expanded. If word is
unquoted, all lines of the here-document are subjected to parameter expansion, command sub
stitution, and arithmetic expansion.
--
-o) Pascal Bleser ATOS Origin/Aachen(DE) |
/\\ <pascal.bleser@atosorigin.com> |
_\_v <guru@linuxbe.org> |
---------------------------------------------|
Jesus saves,Buddha makes incremental backups :
---------------------------------------------'
_______________________________________________
Linux Mailing List
LCP - 11 Mai - http://www.unixtech.be/lcp.php
Archives: http://www.unixtech.be/mailman/listinfo/linux