LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 02-24-2004, 11:15 AM   #1
lugoteehalt
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
smegma
lugo@debian:~$ echo $filth
2
lugo@debian:~$
lugo@debian:~$ echo !$filth
echo Ffilth
Ffilth
lugo@debian:~$ echo !
!
lugo@debian:~$ echo !$
echo !
!

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

Rep: Reputation: 79
I think !$ contains the last command used in the bash shell. This should be in the bash man page.
 
Old 02-24-2004, 01:47 PM   #3
frieza
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: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
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, 04:59 AM   #4
lugoteehalt
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.
 
  


Reply


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 12:39 AM
a strange thing wizard7423 Slackware 3 03-17-2005 09:08 AM
Odd thing happened in YOU today iain.ross SUSE / openSUSE 3 01-30-2005 08:09 AM
strange thing cristi1979 Linux - Security 4 07-11-2003 12:03 PM
Strange thing about pine Half_Elf Linux - Software 6 06-05-2003 01:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:42 PM.

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