Double asterisks


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Double asterisks
# 1  
Old 06-14-2008
Double asterisks

When I go
Code:
$ echo *

I get a directory listing.

When I go
Code:
$ echo * *

I get a directory listing, followed by a second identical directory listing.

When I go
Code:
$ echo **

I only get one directory listing. What happens to the second asterisk in this case? Why doesn't it expand? I haven't been able to sleep because of this question. Can anyone help?
# 2  
Old 06-14-2008
In the first case your have two arguments and in the second case you have one argument. If an argument contains an asterisk, the argument is expanded into a list of filenames that match it. Suppose you have a directory with a single file names "b". This command:
echo b*
will still echo "b". The asterisk stands for "zero or more characters". The "b*" pattern would also match files like b1 b2 bbbbb and so on. Now consider:
echo b**
Remember that b* matched a simple b. There is no need for extra characters to satisfy the asterisk. So b* b** b*** b***** and so on all will match a file named just "b". In the same way, * matches all filenames (except those that start with a dot). And ** *** **** and so on just match the same list as a simple *. However, time is spent processing those superfluous asterisks, so it is a waste or resources.
# 3  
Old 06-14-2008
Thanks for the great explanation, Perderabo. It makes sense to me now.

PS- thanks for the quick reply. I just discovered this forum and it rocks!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing multiple asterisks in vi

i need to replace all occurrences of "period asterisk" as it is shown in this: blah blah .*:.*:.* blah blah with: :: so that the end result looks like this: blah blah :: blah blah I tried different variations of the following but it didint work: %s_ .*:.*:.* _ :: _g (2 Replies)
Discussion started by: SkySmart
2 Replies

2. UNIX for Advanced & Expert Users

Show Asterisks when changing Password

Note: **Showing Asterisks when using SUDO is not what I am looking for. That method is well documented** Short Description: We have a requirement where users want to see that they are typing a password when logging into a RedHat box or when they are changing their password -- instead of... (1 Reply)
Discussion started by: caperjm
1 Replies

3. Shell Programming and Scripting

Eliminate or ignore asterisks in data when parsing

I have data file that has this in it: data.txt ......... ......... PPJ97**2017PPJ97**2017-03-21-13.35.15.887208********************START ERROR LOGGING****************** PPJ97**2017-03-21-13.35.15.887208** PROMPT APPLICATION ERROR ** PPJ97**2017-03-21-13.35.15.887208** IN TIMESTAMP |... (1 Reply)
Discussion started by: SkySmart
1 Replies

4. Shell Programming and Scripting

Regexp to separated rows by "asterisks-new line" in awk

Hello to all, I have the text file below, how would be the REGEXP to set the RS to separate registers by asterisks-newline-asterisks (highlighted in red) and FS as the default, in order that the fourth field ($4) always be the number after REG (in blue)? I'm trying with code below, but is... (5 Replies)
Discussion started by: Ophiuchus
5 Replies

5. Shell Programming and Scripting

Create new file when three asterisks are encountered.

Hi All, I have a text file which is currently formatted like this: TEXT1 *** TEXT2 *** TEXT3 *** I want text before *** to go into separate files. For example, 1.dat TEXT1 (5 Replies)
Discussion started by: shoaibjameel123
5 Replies

6. Shell Programming and Scripting

build a string of asterisks elegantly

hi in a script i hate string definitions like str="***********************************" who can help to build a 50 character long string of asterisks more elegantly? any hint is welcome thanks and regards lazy (18 Replies)
Discussion started by: lazybaer
18 Replies

7. Shell Programming and Scripting

need to replace asterisks

I need to replace occurrences of twelve asterisks "************" with the string " 0000000.00" . Note that there are two spaces in front of the first zero. How can I do this using awk or sed? (3 Replies)
Discussion started by: mustang_9333
3 Replies

8. Shell Programming and Scripting

Assistence With Using Asterisks in GREP Expressions

I am attempting to find all complete words which contain an asterisk at the beginning and the end - for instance, "*Hello?*" or "*you*". From what I've read, I would have thought that the following expression would do that just fine: \<\*.*\*\> \< denoting the beginning of a word. \*... (12 Replies)
Discussion started by: MagusScythe
12 Replies

9. Programming

double pow (double x, double y) -- problems

This is the code and I'm wondering why line 14: a = ... and line 16: b = ... is wrong. This is the first time I've tried to use this. Please help me. #include <stdio.h> #include <math.h> // The link and how the double pow is used. // // http://www.nextdawn.nl/c-reference/pow.php //... (2 Replies)
Discussion started by: pwanda
2 Replies
Login or Register to Ask a Question