You are not logged in.
Pages: 1
asd(){
.--. .---.
/:. '. .' .. '._.---.
/:::-. \.-"""-;` .-:::. .::\
/::'| `\/ _ _ \' `\:' ::::|
__.' | / (o|o) \ `'. ':/
/ .:. / | ___ | '---'
| ::::' /: (._.) .:\
\ .=' |:' :::|
`""` \ .-. ':/
'---`|I|`---'
'-'
}
echo $asd
how can i make something like this to work?
what i get now is:
1.sh: line 6: syntax error near unexpected token `o'
1.sh: line 6: ` __.' | / (o|o) \ `'. ':/'
Offline
bash functions expect bash commands. You either want to store that in a variable or use a heredoc, e.g.:
foo() {
cat<<EOF
.--. .---.
/:. '. .' .. '._.---.
/:::-. \.-"""-;` .-:::. .::\
/::'| `\/ _ _ \' `\:' ::::|
__.' | / (o|o) \ `'. ':/
/ .:. / | ___ | '---'
| ::::' /: (._.) .:\
\ .=' |:' :::|
`""` \ .-. ':/
'---`|I|`---'
'-'
EOF
}
Offline
EDIT: doh, too slow!
asd="
.--. .---.
/:. '. .' .. '._.---.
/:::-. \.-"""-;` .-:::. .::\
/::'| `\/ _ _ \' `\:' ::::|
__.' | / (o|o) \ `'. ':/
/ .:. / | ___ | '---'
| ::::' /: (._.) .:\
\ .=' |:' :::|
`""` \ .-. ':/
'---`|I|`---'
'-'
"
echo $asd
or
asd() {
cat <<EOT
.--. .---.
/:. '. .' .. '._.---.
/:::-. \.-"""-;` .-:::. .::\
/::'| `\/ _ _ \' `\:' ::::|
__.' | / (o|o) \ `'. ':/
/ .:. / | ___ | '---'
| ::::' /: (._.) .:\
\ .=' |:' :::|
`""` \ .-. ':/
'---`|I|`---'
'-'
EOT
}
asd
Last edited by fukawi2 (2011-05-22 01:17:22)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
You have to escape some of the special characters ( ` should be \` , " should be \" and \ should be \\. Putting the hole string in $" ... " literals will do the rest of the magic. See man bash, under the headline "quoting" for more details.
#!/bin/bash
echo $"
.--. .---.
/:. '. .' .. '._.---.
/:::-. \\.-\"\"\"-;\` .-:::. .::\\
/::'| \`\\/ _ _ \\' \`\\:' ::::|
__.' | / (o|o) \\ \`'. ':/
/ .:. / | ___ | '---'
| ::::' /: (._.) .:\\
\\ .=' |:' :::|
\`\"\"\` \\ .-. ':/
'---\`|I|\`---'
'-'
"
should procude:
.--. .---.
/:. '. .' .. '._.---.
/:::-. \.-"""-;` .-:::. .::\
/::'| `\/ _ _ \' `\:' ::::|
__.' | / (o|o) \ `'. ':/
/ .:. / | ___ | '---'
| ::::' /: (._.) .:\
\ .=' |:' :::|
`""` \ .-. ':/
'---`|I|`---'
'-'
edit: /mpfh too slow as well.
Last edited by Wey (2011-05-22 01:21:12)
Offline
OK, thank you guys!
Offline
Hi,
you don't need to worry about that escaping stuff when placing quotes around the heredoc-delimiter ("EOT"). So this works:
asd() {
cat <<"EOT"
.--. .---.
/:. '. .' .. '._.---.
/:::-. \.-"""-;` .-:::. .::\
/::'| `\/ _ _ \' `\:' ::::|
__.' | / (o|o) \ `'. ':/
/ .:. / | ___ | '---'
| ::::' /: (._.) .:\
\ .=' |:' :::|
`""` \ .-. ':/
'---`|I|`---'
'-'
EOT
}
asd
Offline
Pages: 1