Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-24-2004, 12:15 PM   #1
Senior Member
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
A strange thing happened with !

Tested a piece of a shell script at the command line and got an odd and interesting-looking result. (Incidentally I realise there should be a space between the ! and $.)

Question is: Why does the first line give the output it does - the second and thrid lines?

lugo@debian:~$ if [ !$filth ]; then echo 'smegma'; fi
if [ fifilth ]; then echo 'smegma'; fi
lugo@debian:~$ echo $filth
lugo@debian:~$ echo !$filth
echo Ffilth
lugo@debian:~$ echo !
lugo@debian:~$ echo !$
echo !

Thanks any help.
Old 02-24-2004, 02:39 PM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
I think !$ contains the last command used in the bash shell. This should be in the bash man page.
Old 02-24-2004, 02:47 PM   #3
Senior Member
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 404Reputation: 404Reputation: 404Reputation: 404Reputation: 404
he's right... look up the 'history' command (info history, NOT man hisory) the
!X will pull up command X in the history....
Old 02-26-2004, 05:59 AM   #4
Senior Member
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215

Original Poster
Blog Entries: 2

Rep: Reputation: 49
Thanks - that's very interesting.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Funny thing happened on the way...... Rick069 Mandriva 5 11-01-2005 01:39 AM
a strange thing wizard7423 Slackware 3 03-17-2005 10:08 AM
Odd thing happened in YOU today iain.ross SUSE / openSUSE 3 01-30-2005 09:09 AM
strange thing cristi1979 Linux - Security 4 07-11-2003 01:03 PM
Strange thing about pine Half_Elf Linux - Software 6 06-05-2003 02:52 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:32 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration