Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
BASH mystery 2:
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
mansniks
Apprentice
Apprentice


Joined: 19 Nov 2007
Posts: 290

PostPosted: Sat Oct 04, 2008 9:31 am    Post subject: BASH mystery 2: Reply with quote

echo "echo \"!\""
bash: !\: event not found
Back to top
View user's profile Send private message
Evildad
Guru
Guru


Joined: 15 Apr 2004
Posts: 475

PostPosted: Sat Oct 04, 2008 9:39 am    Post subject: Reply with quote

echo 'echo \"!\" '

€dit: What is your expected output?

Quote:
echo !


should be done with
Code:
echo 'echo !'
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Sat Oct 04, 2008 12:45 pm    Post subject: Reply with quote

When you type a word preceeded by an "!", bash thinks you want to recall a previous command or "event". The message indicates no matching event was found in your recent command history. You can suppress the special meaning of ! by quoting it, for example: \!

echo "echo \"\!\""
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
mansniks
Apprentice
Apprentice


Joined: 19 Nov 2007
Posts: 290

PostPosted: Sat Oct 04, 2008 1:13 pm    Post subject: Reply with quote

echo "echo \"\!\""
echo "\!"

(so can't without '..)

Any html, where it is best to read about ' and " differences in bash? (somehow those long manuals are hard to browse and find something in them..)
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Sat Oct 04, 2008 1:16 pm    Post subject: Reply with quote

for bash?

http://bash-hackers.org/wiki/doku.php?id=syntax:words to understand
http://www.grymoire.com/Unix/Quote.html will tell you how. -- Optimally, you should quote every parameter expansion ($foo).
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
notHerbert
Advocate
Advocate


Joined: 11 Mar 2008
Posts: 2228
Location: 45N 73W

PostPosted: Sat Oct 04, 2008 2:18 pm    Post subject: Reply with quote

Code:
~ mybox $ echo echo !
echo !
8)
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Sat Oct 04, 2008 2:21 pm    Post subject: Reply with quote

see this is the problem
HE never stated what he /really/ wants, what his desired output is...

Quote:

bashphorism 1: the questioner's first description of the problem/question will be misleading.
bashphorism 2: The questioner will keep changing the original question until it drives the helpers in the channel insane.
"Offtopicness will continue until someone asks a bash question that falls under bashphorisms 1 and/or 2, and greycat gets pissed off."
Bashphorism 4:The questioner will not read and apply the answers he is given but will instead continue to practice b1 and b2
"The ignorant will continually mis-educate the other noobies"
When given a choice of two solutions, the newbie will always choose the more complicated, or less portable, solution.

http://wooledge.org/mywiki/XyProblem

_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
Evildad
Guru
Guru


Joined: 15 Apr 2004
Posts: 475

PostPosted: Sat Oct 04, 2008 2:25 pm    Post subject: Reply with quote

sh-3.2$ echo echo !
echo !

Hopefully he'll let us know what he really wants to do :lol:
Back to top
View user's profile Send private message
notHerbert
Advocate
Advocate


Joined: 11 Mar 2008
Posts: 2228
Location: 45N 73W

PostPosted: Sat Oct 04, 2008 2:45 pm    Post subject: Reply with quote

mansniks wrote:
Any html, where it is best to read about ' and " differences in bash? (somehow those long manuals are hard to browse and find something in them..)
Code:
~ mybox $ FOO=123
~ mybox $ echo "$FOO"
123
~ mybox $ echo '$FOO'
$FOO
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum