View previous topic :: View next topic |
Author |
Message |
dongfangxunlei n00b
Joined: 30 Jan 2013 Posts: 40
|
Posted: Fri Dec 06, 2013 6:13 am Post subject: echo !(bin|sbin) |
|
|
This command not work in gentoo bash.It said " !: event not found"
What is the problem? |
|
Back to top |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9526 Location: beyond the rim
|
Posted: Fri Dec 06, 2013 7:23 am Post subject: |
|
|
Maybe if you'd say what you're trying to do someone could help. Pretty sure it isn't valid bash syntax, so no idea what that command is supposed to do. |
|
Back to top |
|
|
lexflex Guru
Joined: 05 Mar 2006 Posts: 363 Location: the Netherlands
|
Posted: Fri Dec 06, 2013 10:03 am Post subject: |
|
|
! executes the last instance of a command issued with the then used parameters ( it gets this from .bash_history i guess).
!! executes the last command.
( so !ls gives the last instance of ls, which might have been ls, or ls -all ).
However, as Genone said, the command is not a valid command, so you cant re-execute the last instance of that ....
So, indeed, the question is: what do you want to do exactly?
Alex.
EDIT: ok , apparently '!' is some feature of echo in your example, not a command by itself.
Last edited by lexflex on Fri Dec 06, 2013 2:58 pm; edited 1 time in total |
|
Back to top |
|
|
dongfangxunlei n00b
Joined: 30 Jan 2013 Posts: 40
|
Posted: Fri Dec 06, 2013 2:03 pm Post subject: |
|
|
In debian ,this will show all files' and directorys' name except bin,sbin.
for example,if current directory has these files: a ,b ,c ,d
when I execute "echo !(a|b)" in debian,it will show c d
I also copy gentoo's bash to debian and run it in debian ,the same problem occur again.So this must be a bug in gentoo's bash. |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10589 Location: Somewhere over Atlanta, Georgia
|
Posted: Fri Dec 06, 2013 3:06 pm Post subject: |
|
|
Could you possibly find the place in the Debian bash man page where this behavior is documented and post it here? Is it at all possible that you're not using bash on Debian?
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
lexflex Guru
Joined: 05 Mar 2006 Posts: 363 Location: the Netherlands
|
Posted: Fri Dec 06, 2013 3:14 pm Post subject: |
|
|
John R. Graham wrote: | Could you possibly find the place in the Debian bash man page where this behavior is documented and post it here? Is it at all possible that you're not using bash on Debian?
- John |
Mmm, indeed. Apparently, the default in Debian is Dash or bash:
https://wiki.debian.org/Shell
So , maybe check the shell you use in Debian using 'echo $SHELL'
Alex. |
|
Back to top |
|
|
dongfangxunlei n00b
Joined: 30 Jan 2013 Posts: 40
|
Posted: Sat Dec 07, 2013 3:01 am Post subject: |
|
|
What a strange day! I found it work again just now.
gentoo@localhost ~ $ cd /
gentoo@localhost / $ which echo
/bin/echo
gentoo@localhost / $ file /bin/echo
/bin/echo: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, stripped
gentoo@localhost / $ echo !(bin|sbin)
boot dev etc home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sys tmp usr var
gentoo@localhost / $ ls
bin dev home lib32 libx32 media opt root sbin tmp var
boot etc lib lib64 lost+found mnt proc run sys usr
gentoo@localhost / $ |
|
Back to top |
|
|
steveL Watchman
Joined: 13 Sep 2006 Posts: 5153 Location: The Peanut Gallery
|
Posted: Sat Dec 07, 2013 4:54 am Post subject: |
|
|
dongfangxunlei wrote: | In debian ,this will show all files' and directorys' name except bin,sbin. |
This is the extglob shell setting; you need to put: in your ~/.bashrc to enable it for your bash logins (you'll see it bails out for non-interactive shells already.)
It changes how bash "parses" (actually tokenises, but it's part of the same process) so it doesn't default to on, though it is very useful. ISTR it defaults to on in ebuilds now. |
|
Back to top |
|
|
|