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
filelib(3erl)						     Erlang Module Definition						     filelib(3erl)

NAME
filelib - File utilities, such as wildcard matching of filenames DESCRIPTION
This module contains utilities on a higher level than the file module. The module supports Unicode file names, so that it will match against regular expressions given in Unicode and that it will find and process raw file names (i.e. files named in a way that does not confirm to the expected encoding). If the VM operates in Unicode file naming mode on a machine with transparent file naming, the fun() provided to fold_files/5 needs to be prepared to handle binary file names. For more information about raw file names, see the file module. DATA TYPES
filename() = string() | atom() | DeepList | RawFilename DeepList = [char() | atom() | DeepList] RawFilename = binary() If VM is in unicode filename mode, string() and char() are allowed to be > 255. RawFilename is a filename not subject to Unicode translation, meaning that it can contain characters not conforming to the Unicode encoding expected from the filesystem (i.e. non-UTF-8 characters although the VM is started in Unicode filename mode). dirname() = filename() EXPORTS
ensure_dir(Name) -> ok | {error, Reason} Types Name = filename() | dirname() Reason = posix() -- see file(3erl) The ensure_dir/1 function ensures that all parent directories for the given file or directory name Name exist, trying to create them if necessary. Returns ok if all parent directories already exist or could be created, or {error, Reason} if some parent directory does not exist and could not be created for some reason. file_size(Filename) -> integer() The file_size function returns the size of the given file. fold_files(Dir, RegExp, Recursive, Fun, AccIn) -> AccOut Types Dir = dirname() RegExp = regular_expression_string() Recursive = true|false Fun = fun(F, AccIn) -> AccOut AccIn = AccOut = term() The fold_files/5 function folds the function Fun over all (regular) files F in the directory Dir that match the regular expression RegExp (see the re module for a description of the allowed regular expressions). If Recursive is true all sub-directories to Dir are processed. The regular expression matching is done on just the filename without the directory part. If Unicode file name translation is in effect and the file system is completely transparent, file names that cannot be interpreted as Unicode may be encountered, in which case the fun() must be prepared to handle raw file names (i.e. binaries). If the regular expression contains codepoints beyond 255, it will not match file names that do not conform to the expected character encoding (i.e. are not encoded in valid UTF-8). For more information about raw file names, see the file module. is_dir(Name) -> true | false Types Name = filename() | dirname() The is_dir/1 function returns true if Name refers to a directory, and false otherwise. is_file(Name) -> true | false Types Name = filename() | dirname() The is_file/1 function returns true if Name refers to a file or a directory, and false otherwise. is_regular(Name) -> true | false Types Name = filename() The is_regular/1 function returns true if Name refers to a file (regular file), and false otherwise. last_modified(Name) -> {{Year,Month,Day},{Hour,Min,Sec}} | 0 Types Name = filename() | dirname() The last_modified/1 function returns the date and time the given file or directory was last modified, or 0 if the file does not exist. wildcard(Wildcard) -> list() Types Wildcard = filename() | dirname() The wildcard/1 function returns a list of all files that match Unix-style wildcard-string Wildcard . The wildcard string looks like an ordinary filename, except that certain "wildcard characters" are interpreted in a special way. The following characters are special: ? : Matches one character. * : Matches any number of characters up to the end of the filename, the next dot, or the next slash. [Character1,Character2,...] : Matches any of the characters listed. Two characters separated by a hyphen will match a range of characters. Example: [A-Z] will match any uppercase letter. {Item,...} : Alternation. Matches one of the alternatives. Other characters represent themselves. Only filenames that have exactly the same character in the same position will match. (Match- ing is case-sensitive; i.e. "a" will not match "A"). Note that multiple "*" characters are allowed (as in Unix wildcards, but opposed to Windows/DOS wildcards). Examples: The following examples assume that the current directory is the top of an Erlang/OTP installation. To find all .beam files in all applications, the following line can be used: filelib:wildcard("lib/*/ebin/*.beam"). To find either .erl or .hrl in all applications src directories, the following filelib:wildcard("lib/*/src/*.?rl") or the following line filelib:wildcard("lib/*/src/*.{erl,hrl}") can be used. To find all .hrl files in either src or include directories, use: filelib:wildcard("lib/*/{src,include}/*.hrl"). To find all .erl or .hrl files in either src or include directories, use: filelib:wildcard("lib/*/{src,include}/*.{erl,hrl}") wildcard(Wildcard, Cwd) -> list() Types Wildcard = filename() | dirname() Cwd = dirname() The wildcard/2 function works like wildcard/1 , except that instead of the actual working directory, Cwd will be used. Ericsson AB stdlib 1.17.3 filelib(3erl)
All times are GMT -4. The time now is 06:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy