-   Programming (
-   -   A strange thing happened with ! (

lugoteehalt 02-24-2004 12:15 PM

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.

david_ross 02-24-2004 02:39 PM

I think !$ contains the last command used in the bash shell. This should be in the bash man page.

frieza 02-24-2004 02:47 PM

he's right... look up the 'history' command (info history, NOT man hisory) the
!X will pull up command X in the history....

lugoteehalt 02-26-2004 05:59 AM

Thanks - that's very interesting.

All times are GMT -5. The time now is 04:52 AM.