wildcard in bash shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting wildcard in bash shell script
# 8  
Old 09-08-2010
Like Corona688 says, it might be that you are listing the content of directories, try:
Code:
ls -d ./*

and see if that makes a difference
# 9  
Old 09-08-2010
This is not a problem in my case, since all files in my current directory do not have a name starting with ".".

Quote:
Originally Posted by methyl
If the only files in the directory have names starting with "." (like ".profile) they will not match "*".

To see them:

Code:
ls ./.??*



---------- Post updated at 10:00 AM ---------- Previous update was at 09:55 AM ----------

thanks for suggestion. I tried, and when I run the script, it gave the same error message:
ls: ./*: No such file or directory.

It looks like the script can not expand '*'. I just can not understand why.

Quote:
Originally Posted by Scrutinizer
Like Corona688 says, it might be that you are listing the content of directories, try:
Code:
ls -d ./*

and see if that makes a difference
# 10  
Old 09-08-2010
It's staring me in the face.

You are starting bash with the "-f" switch set. This turns off the filename generation features of bash. In other words it stops the "*" working.

Lose the "-f" .
This User Gave Thanks to methyl For This Post:
# 11  
Old 09-08-2010
thanks a lot! It works when I drop off '-f'.

One more question: why does it work when I use '-f' in c shell?

Quote:
Originally Posted by methyl
It's staring me in the face.

You are starting bash with the "-f" switch set. This turns off the filename generation features of bash. In other words it stops the "*" working.

Lose the "-f" .
# 12  
Old 09-08-2010
"-f" has a different meaning in csh
Code:
$ man csh | grep -A1 '[[:space:]]\-f'
     -f     The shell will start faster, because it will neither search for nor execute commands from the file .cshrc in the
            invoker's home directory.  Note: if the environment variable HOME is not set, fast startup is the default.

This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ? --- Post updated at 08:39 AM --- in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
Discussion started by: i4ismail
3 Replies

2. Shell Programming and Scripting

Different behavior between bash shell and bash script for cmd

So I'm trying to pass certain json elements as env vars and use them later on in a script. Sample json: JSON='{ "Element1": "file-123456", "Element2": "Name, of, company written in, a very weird way", "Element3": "path/to/some/file.txt", }' (part of the) script: for s... (5 Replies)
Discussion started by: da1
5 Replies

3. Shell Programming and Scripting

Wildcard in bash script

Hi there, I am pretty new to linux scripting so .. I am writing a script to loop through all my directories of sequence files in order to do stuff with them (trimming, normalizing, stuff that one would do with sequence files). Here I need to pick out files that match each other. The files... (10 Replies)
Discussion started by: jahndavik
10 Replies

4. Shell Programming and Scripting

Bash shell script to check if script itself is running

hi guys we've had nagios spewing false alarm (for the umpteenth time) and finally the customer had enough so they're starting to question nagios. we had the check interval increased from 5 minutes to 2 minutes, but that's just temporary solution. I'm thinking of implementing a script on the... (8 Replies)
Discussion started by: hedkandi
8 Replies

5. Shell Programming and Scripting

What does " shell wildcard " shell script?

Hi, I just wondering what does " shell wildcard " Thank (1 Reply)
Discussion started by: guidely
1 Replies

6. Shell Programming and Scripting

help- wildcard not working in shell

hi, i need to check the existence of all files starting with abc in a directory. The code works fine with a particular file name, but the file existence is not detected when i use wildcard character (abc*) kindly suggest what could be the issue :confused: src_filename1=$AI_LANDING/abc*... (11 Replies)
Discussion started by: spirit10
11 Replies

7. Shell Programming and Scripting

Problem when concatinating wildcard onto file location in bash script

I am having difficulty with the following script: #! /bin/bash filelist=~/data/${1}* ~/./convertFile $filelist ~/temp/outputEssentially, there are a large number of files in the directory ~/data, each with a four-letter code at the beginning (eg. aaaa001 aaaa002 bbbb001 bbbb002 etc). The... (11 Replies)
Discussion started by: Lears_Fool
11 Replies

8. UNIX for Dummies Questions & Answers

Bash Wildcard Question

Hi, I am writing a BASH script. In a directory I have a bunch of files of various filename structures. How do I list all the filenames that begin with either a capital or lowercase A or T. Is there one command that could replace the following 4: ls A* ls a* ls T* ls t* Thanks. Mike (3 Replies)
Discussion started by: msb65
3 Replies

9. Shell Programming and Scripting

globbing, $# is too high after wildcard expansion in bash script

How can I pass in an argument such as "*.k" to a bash script without having to double-quote *.k and not having *.k `glob` to match all files in the pattern? I tried using noglob in my script but this didn't work the way I thought it would.. expansion is still occuring, $# is higher than I... (3 Replies)
Discussion started by: zoo591
3 Replies

10. UNIX for Dummies Questions & Answers

Find wildcard .shtml files in wildcard directories and removing them- How's it done?

I'm trying to figure out how to build a small shell script that will find old .shtml files in every /tgp/ directory on the server and delete them if they are older than 10 days... The structure of the paths are like this: /home/domains/www.domain2.com/tgp/ /home/domains/www.domain3.com/tgp/... (1 Reply)
Discussion started by: Neko
1 Replies
Login or Register to Ask a Question