Wildcard in Cshell find command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wildcard in Cshell find command
# 1  
Old 02-11-2009
Wildcard in Cshell find command

The following command works fine in my cshell script:

set Deliverables = `find . -name "[Dd]eliverables" -print`


The following command does not work:

set LASFiles = `find . -name "*.[Ll][Aa][Ss]" -print`

In the first example, when tested in an if statement, the script will continue whether a folder or file called Deliverables (or deliverables) exists or not.

In the second example the script will post the error "No Match" and hang if no .las (or .LAS) files are present. Apparently there is something that the Cshell does not like about my wildcard. Does anyone know the trick here?

Thanks
# 2  
Old 02-11-2009
Quote:
Originally Posted by phudgens
Does anyone know the trick here?

Don't use the C shell for scripting.
Top Ten Reasons not to use the C shell
Csh problems
Csh Programming Considered Harmful
# 3  
Old 02-12-2009
Am I correct in my conclusion that there is no way in Cshell to find out whether or not files with a particular suffix (ie *.xyz) exist without having anything echoed back to the screen?

Thanks,
Paul H.
# 4  
Old 02-12-2009
In my relentless pursuit of programming perfection, and in answer to my question above, I have discovered that the following code does what I am trying to do in the Cshell:

set pds_files = `find . -name "*.[Pp][Dd][Ss]" -print`
if ("$pds_files" != "") then
...
else
...
endif

This works regardless of the presence or absence of any .pds (or .PDS) files. It does seem, however, that I had tried this code previously in my many various permutations of it. One thing I did differently this time, however, was add empty lines separating parts of my code. Is there any conceivable way that adding empty lines can have such an effect?

While I can appreciate that the Cshell is not the best environment for programming, the thought of converting everything over to the Bourne shell makes me go queasy. I appreciate the input re: various sources of help with cshell programming.

Thanks,

Paul H.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find and replace with wildcard

HI there, I am trying to find and replace with wildcard with data chr1 69511 69511 A G 1/1:0,34:791,78,0:78:34 0/1:55,60:1130,0,1513:99:116 1/1:0,28:630,63,0:63:28 0/1:0,34:626,57,0:57:34 To this chr1 69511 69511 A G homo hetero homo hetero Where I find and replace 0/1 with... (3 Replies)
Discussion started by: daashti
3 Replies

2. UNIX for Advanced & Expert Users

"GET" command retrieves multiple files while using wildcard

Hi All I am using GNU/Linux This is regarding the get command to retrieve files (filename with wild card characters) from remote server. I thought Get command can retrieve only 1 file irrespective of the files it has on the remote server And it is the function of mget to retrieve all... (7 Replies)
Discussion started by: sparks
7 Replies

3. UNIX for Dummies Questions & Answers

passing command output from one command to the next command in cshell

HI Guys, I hope you are well. I am trying to write a script that gets executed every time i open a shell (cshell). I have two questions about that 1) I need to enter these commands $ echo $DISPLAY $ setenv $DISPLAY output_of_echo_$display_command How can i write a... (2 Replies)
Discussion started by: kaaliakahn
2 Replies

4. Shell Programming and Scripting

Wildcard use with SED command

Hello, I am fairly new to Linux in general and I am trying to use SED to make some replacements in a file. Below is sample of what the file is like. <Grouping id="024"><Source>ABC</Source><GroupingKey>000000000816</GroupingKey></Grouping><Grouping... (9 Replies)
Discussion started by: runforfun7
9 Replies

5. Shell Programming and Scripting

find command with wildcard directory

I want to look if there is any file inside a specific directory which was modified before 2 days. I wrote the find command, but the problem is there is one directory and that is a random directory generated by unix, so not sure on how to code for that on the find command. find... (5 Replies)
Discussion started by: srini0603
5 Replies

6. Shell Programming and Scripting

Passing wildcard parameters to find via a variable

I have a script to fix permissions which is made up of blocks like: FS_ROOT=/home/shared/Photos FS_EXCLUDE=( \( -path */.webviews -o -path */.thumbnails \) -prune -o ) find $FS_ROOT ${FS_EXCLUDE} -type d -not -perm 2770 -exec chmod 2770 "{}" \; That fragment works as expected, but no matter... (3 Replies)
Discussion started by: mij
3 Replies

7. UNIX for Dummies Questions & Answers

Tail command with wildcard file name

Please help with the following command tail -f /appdata/logs/alert_audit517.txt | grep "Sep 02" The problem I have is with the file name "alert_audit517.txt". The 3 digit number at the end of the file name changes, so I need the file name to use a wildcard. Ive tried alert_audit***.txt, but... (5 Replies)
Discussion started by: robertson1995
5 Replies

8. Shell Programming and Scripting

Find replace a particular string of data with wildcard

Hi I am having a csv file in which lots of data are available wherein i need to find a particular kind of data and replace it with null value. here is the sample data.. I need to find the string starting with 404-064- and up to the first space i have to remove the data and keep the... (4 Replies)
Discussion started by: aemunathan
4 Replies

9. Solaris

Problem in using wildcard characters in xargs with find

Hi, Under my parent diectory I have directory named "Response" in many of its subfolders. I am interested to see all files with extention .pro in Response Directory. I am giving following command - find . -name "Response" -type d | xargs -i ls -lrt {}/*.pro but it is not giving result. ... (3 Replies)
Discussion started by: sanjay1979
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