?(pattern-list) Optionally matches any one of the given
patterns.
*(pattern-list) Matches zero or more occurrences of the given
patterns.
+(pattern-list) Matches one or more occurrences of the given
patterns.
@(pattern-list) Matches exactly one of the given patterns.
!(pattern-list) Matches anything, except one of the given
patterns.
The key point that rveri seems to be missing is that the shell uses filename pattern matching (not regular expressions) when expanding the arguments that will be passed to ls. Although there are some similarities between pattern matching and regular expression, many of the details are different.
This User Gave Thanks to Don Cragun For This Post:
Thanks,Scrutinizer, Corona, Yoda First 3 worked.. to list all files NOT starting with a :
# Worked well: Seems matching is passed to ls command: " ls -l [!a]bc "
Code:
# ls -l ab[c]
-rw------- 1 useradm users 0 Mar 27 12:57 abc
# ls -l [!a]bc
-rw------- 1 useradm users 0 Mar 26 15:27 bbc
# Worked well: Seems matching is passed to shell.
Code:
# echo [!a]bc
bbc
This is too worked fine, seems matching is done through shell.
Code:
# ls -l !(a)+(bc)
-rw------- 1 useradm users 0 Mar 26 15:27 bbc
-rw------- 1 useradm users 0 Mar 26 15:27 bbcabc
-rw------- 1 useradm users 0 Mar 26 15:27 bbcbbc
#
Yoda, thanks for the manual page,
Don thanks for pointing out the difference of use when "shell uses filename pattern matching" & when "Regular expression uses pattern matching".
Is there a way we can figure out which is shell doing, and which is doing by regular expressions.
For example with the below example: How to figure out which portion is shell or regex performing the operation:
Code:
# ls -l bbcbbc
-rw------- 1 useradm users 0 Mar 26 15:27 bbcbbc
# ls -l !([c-z])?[c][b][b][b-d]
-rw------- 1 useradm users 0 Mar 26 15:27 bbcbbc
echo $SHELL
/usr/bin/ksh
#OS= hp-ux 11.23
Don thanks for pointing out the difference of use when "shell uses filename pattern matching" & when "Regular expression uses pattern matching".
Is there a way we can figure out which is shell doing, and which is doing by regular expressions.
For example with the below example: How to figure out which portion is shell or regex performing the operation:
Code:
# ls -l bbcbbc
-rw------- 1 useradm users 0 Mar 26 15:27 bbcbbc
# ls -l !([c-z])?[c][b][b][b-d]
-rw------- 1 useradm users 0 Mar 26 15:27 bbcbbc
echo $SHELL
/usr/bin/ksh
#OS= hp-ux 11.23
Thanks..
In general, the answer is to read the man pages. But as a high altitude first cut, any unquoted argument passed to the shell that is not a parameter expansion (i.e., $name or ${...name...} that is not part of a shell command lanuage construct (e.g., if, then, else, fi, case, esac, ...) will be subject to pathname expansion.
This User Gave Thanks to Don Cragun For This Post:
Hello
I'm using cygwin and wouldlike extract information from an xml file according specific values, but don't know how.
Let's say in a file content looks like this:
<tab>
SURNAME=Mustermann
NAME=Max
CUSTOMER SINCE= 18.01.2000
ADDRESS=Birmingham
... (2 Replies)
Hello,
I have been browsing through the forum, but unable to find a solution for my requirement.
I need to go through a file and search for /home/users and insert a # symbol at the start /home/users. Example output is #/home/users.
Can you please help me with the awk or sed command for... (1 Reply)
I am trying to extract a string from a line of text. Currently I am using
grep -o 'startofstring(.........'
The string is not always the same size.
The string I'm trying to extract starts with 'test(' ends with ')'.
ex "blah,blah,blah,test(stringoftext),blah blah"
How do I... (4 Replies)
Dear Experts,
I wanted to plot a graph with respect to values from a file.
I'm doing it with Excel 2007, but I want to create the chart in script itself.
I searched in internet for GNUPLOt. But I couldn't understand anything.
Here is my situation. I have a file having values separated by "|".... (7 Replies)
I need to change a pattern with single quotes
# echo "serversignature: 'On'"
serversignature: 'On'
I did
# echo "serversignature: 'On'" | sed 's/.*serversignature.*/serversignature: 'Off'/'
serversignature: Off
The output I need is with single quotes. But its swallowing it.
... (2 Replies)
Hello. I'm new here and i'm new to slack (concept) as well. I made a connection for pppoe with pppoe-setup, bringed up eth0 with ifconfig but when i try pppoe-connect i get "Cannot determine ethernet address for proxy ARP" and with pppoe-start i get "child pppd process terminated". How can i make... (0 Replies)
Hello all,
I`ve the following problem - I cannot start inetd in any way possible:
bash-3.00# svcs inetd
STATE STIME FMRI
offline Jul_30 svc:/network/inetd:default
bash-3.00#
bash-3.00# svcadm enable -r inetd
bash-3.00# svcs inetd
STATE STIME FMRI... (6 Replies)
How can I do this? Actually I have a file which contains a path
e.g.
/home/john/Music/hello.mp3
and I want to take only the filename (hello.mp3) So, I need to read the file from its end to its start till the character "/"
Is this possible?
Thanks, I am sure you'll not disappoint me here!
Oh,... (9 Replies)
Hi,
I'm writing a script and have become stuck trying to define a variable (COMP) by adding an elapsed time (ELAPSE e.g 00:55) to a start time (START e.g 23:50).
Can anybody give me a solution as to how I can get a completion time in hh:mm from the variables above?
thanks
Richard (4 Replies)