Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
echo !(bin|sbin)
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
dongfangxunlei
n00b
n00b


Joined: 30 Jan 2013
Posts: 40

PostPosted: Fri Dec 06, 2013 6:13 am    Post subject: echo !(bin|sbin) Reply with quote

This command not work in gentoo bash.It said " !: event not found"
What is the problem?
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9526
Location: beyond the rim

PostPosted: Fri Dec 06, 2013 7:23 am    Post subject: Reply with quote

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
View user's profile Send private message
lexflex
Guru
Guru


Joined: 05 Mar 2006
Posts: 363
Location: the Netherlands

PostPosted: Fri Dec 06, 2013 10:03 am    Post subject: Reply with quote

! 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
View user's profile Send private message
dongfangxunlei
n00b
n00b


Joined: 30 Jan 2013
Posts: 40

PostPosted: Fri Dec 06, 2013 2:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10589
Location: Somewhere over Atlanta, Georgia

PostPosted: Fri Dec 06, 2013 3:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
lexflex
Guru
Guru


Joined: 05 Mar 2006
Posts: 363
Location: the Netherlands

PostPosted: Fri Dec 06, 2013 3:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
dongfangxunlei
n00b
n00b


Joined: 30 Jan 2013
Posts: 40

PostPosted: Sat Dec 07, 2013 3:01 am    Post subject: Reply with quote

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
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Sat Dec 07, 2013 4:54 am    Post subject: Reply with quote

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:
Code:
shopt -s extglob
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
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