Sponsored Content
Top Forums Shell Programming and Scripting Unable to find files using wildcard on AIX. Post 303044230 by MadeInGermany on Monday 17th of February 2020 04:40:41 AM
Old 02-17-2020
(@Neo, nothing was really missing. I was able to construct the output from the given input sample and the given code. And no error message.)

The * in shell glob and find glob means every - even zero - amount of characters, so have another ? that means one character.
Further, you can egrep -v '/BACKUP/|/REJECTED/' the unwanted files, but most efficient is to let find prune=skip these directories.
As a rule of thumb, have the pruned directories first and continue with -o=OR=OTHERWISE.
Code:
find /tmp/custom -type d \( -name "BACKUP" -o -name "REJECTED" \) -prune -o -type f \( -name '*.xml?*' -o -name "*.js?*" \) -print

You must explicitly print on the desired branch in order to not implicitly print on both branches.
Llast but not least, *.js?* covers *.jsp?* so the letter is not needed. (Perhaps you want -name "*.js?*" \! -name "*.jsp" or -name "*.js??*"?)

Last edited by MadeInGermany; 02-17-2020 at 05:52 AM.. Reason: The -prune was missing
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Wildcard in Cshell find command

The following command works fine in my cshell script: set Deliverables = `find . -name "eliverables" -print` The following command does not work: set LASFiles = `find . -name "*." -print` In the first example, when tested in an if statement, the script will continue whether a... (3 Replies)
Discussion started by: phudgens
3 Replies

3. 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

4. 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

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. UNIX for Dummies Questions & Answers

Unable to find files using wild card search

Hi All, My server is AIX and i am trying to search for a file in a specific path in directory. The file name can be of two types: Position_20131114.csv Position123333_20131114.csv I am trying to assign a SOURCEFILE variable as mentioned below:, but i am unable to find/locate the files... (2 Replies)
Discussion started by: abhi_123
2 Replies

7. UNIX for Dummies Questions & Answers

Unable to find files, those can be present anywhere in the directory tree,based on its creation date

Hi I am unable to find files, those are present anywhere in the same directory tree, based on the creation date. I need to find the files with their path, as I need to create them in another location and move them. I need some help with a script that may do the job. Please help (2 Replies)
Discussion started by: sam192837465
2 Replies

8. 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

9. AIX

Issue with wildcard in filename (AIX 7.1.0.0)

Hi, This has been pestering me for quite a while, any help will be highly appreciated The current directory has a file with below name npidata_20050523-20171210.csv The below wildcard matched the above file ls -ltr npidata_????????-201712??.csv But when the part '201712' is put... (6 Replies)
Discussion started by: zulfi123786
6 Replies

10. Shell Programming and Scripting

Unable to grep using wildcard in a file.

I wish to check if my file has a line that does not start with '#' and has 1. Listen and 2. 443 echo "Listen 443" > test.out grep 'Listen *443' test.out | grep -v '#' Listen 443 The above worked fine but when the entry changes to the below the grep fails... (2 Replies)
Discussion started by: mohtashims
2 Replies
glob(n) 						       Tcl Built-In Commands							   glob(n)

__________________________________________________________________________________________________________________________________________________

NAME
glob - Return names of files that match patterns SYNOPSIS
glob ?switches? pattern ?pattern ...? _________________________________________________________________ DESCRIPTION
This command performs file name ``globbing'' in a fashion similar to the csh shell. It returns a list of the files whose names match any of the pattern arguments. If the initial arguments to glob start with - then they are treated as switches. The following switches are currently supported: | -directory directory | Search for files which match the given patterns starting in the given directory. This allows searching of directories whose name | contains glob-sensitive characters without the need to quote such characters explicitly. This option may not be used in conjunction | with -path. | -join | The remaining pattern arguments are treated as a single pattern obtained by joining the arguments with directory separators. -nocomplain Allows an empty list to be returned without error; without this switch an error is returned if the result list would be empty. | -path pathPrefix | Search for files with the given pathPrefix where the rest of the name matches the given patterns. This allows searching for files | with names similar to a given file even when the names contain glob-sensitive characters. This option may not be used in conjunc- | tion with -directory. | -types typeList | Only list files or directories which match typeList, where the items in the list have two forms. The first form is like the -type | option of the Unix find command: b (block special file), c (character special file), d (directory), f (plain file), l (symbolic | link), p (named pipe), or s (socket), where multiple types may be specified in the list. Glob will return all files which match at | least one of the types given. | The second form specifies types where all the types given must match. These are r, w, x as file permissions, and readonly, hidden | as special permission cases. On the Macintosh, MacOS types and creators are also supported, where any item which is four characters | long is assumed to be a MacOS type (e.g. TEXT). Items which are of the form {macintosh type XXXX} or {macintosh creator XXXX} will | match types or creators respectively. Unrecognised types, or specifications of multiple MacOS types/creators will signal an error. | The two forms may be mixed, so -types {d f r w} will find all regular files OR directories that have both read AND write permis- | sions. The following are equivalent: | glob -type d * | glob */ | except that the first case doesn't return the trailing ``/'' and is more platform independent. | -- Marks the end of switches. The argument following this one will be treated as a pattern even if it starts with a -. The pattern arguments may contain any of the following special characters: ? Matches any single character. * Matches any sequence of zero or more characters. [chars] Matches any single character in chars. If chars contains a sequence of the form a-b then any character between a and b (inclu- sive) will match. x Matches the character x. {a,b,...} Matches any of the strings a, b, etc. As with csh, a ``.'' at the beginning of a file's name or just after a ``/'' must be matched explicitly or with a {} construct. In addi- tion, all ``/'' characters must be matched explicitly. If the first character in a pattern is ``~'' then it refers to the home directory for the user whose name follows the ``~''. If the ``~'' is followed immediately by ``/'' then the value of the HOME environment variable is used. The glob command differs from csh globbing in two ways. First, it does not sort its result list (use the lsort command if you want the list sorted). Second, glob only returns the names of files that actually exist; in csh no check for existence is made unless a pattern contains a ?, *, or [] construct. PORTABILITY ISSUES
Unlike other Tcl commands that will accept both network and native style names (see the filename manual entry for details on how native and network names are specified), the glob command only accepts native names. Windows For Windows UNC names, the servername and sharename components of the path may not contain ?, *, or [] constructs. On Windows NT, if pattern is of the form ``~username@domain'' it refers to the home directory of the user whose account information resides on the specified NT domain server. Otherwise, user account information is obtained from the local computer. On Windows 95 and 98, glob accepts patterns like ``.../'' and ``..../'' for successively higher up parent directories. Macintosh When using the options, -dir, -join or -path, glob assumes the directory separator for the entire pattern is the standard ``:''. When not using these options, glob examines each pattern argument and uses ``/'' unless the pattern contains a ``:''. SEE ALSO
file(n) KEYWORDS
exist, file, glob, pattern Tcl 8.3 glob(n)
All times are GMT -4. The time now is 05:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy