Sponsored Content
Full Discussion: Ignore .txt in find script
Top Forums Shell Programming and Scripting Ignore .txt in find script Post 303024458 by Neo on Tuesday 9th of October 2018 03:39:31 AM
Old 10-09-2018
Thanks but you could have easily discovered the ! -name flags for find looking at the man page examples:

https://www.unix.com/man-page/linux/1/find/

Code:
       cd /source-dir
       find . -name .snapshot -prune -o \( \! -name *~ -print0 \)|
       cpio -pmd0 /dest-dir

See also:

https://www.unix.com/man-page/sunos/1/find/

Code:
 The following operands are supported:

       path	       A path name of a starting point in the directory hierarchy.

       expression      The first argument that starts with a -, or is a ! or a (, and all  subsequent  arguments  are
		       interpreted as an expression made up of the following primaries and operators. In the descrip-
		       tions, wherever n is used as a primary argument,  it  is  interpreted  as  a  decimal  integer
		       optionally preceded by a plus (+) or minus (-) sign, as follows:

		       +n	more than n

		       n	exactly n

		       -n	less than n


Code:
  -name pattern   True if pattern matches the current file name. Normal shell file  name  generation  characters
		       (see  sh(1))  can  be used. A backslash (\) is used as an escape character within the pattern.
		       The pattern should be escaped or quoted when find is invoked from the shell.

		       Unless the character '.' is explicitly specified in the beginning     of  pattern,  a  current
		       file   name   beginning	 with	'.'   does   not  match  pattern  when	using  /usr/bin/find.
		       /usr/xpg4/bin/find does not make this distinction; wildcard file  name  generation  characters
		       can match file names beginning with '.'.

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find -name "*.txt" in Korn Shell Script

The following find command works on the Korn Shell command line: find . \( ! -name . -prune \) -type f -name "*.txt" -mtime +100 In the particular directory I'm in, the above find will list correctly the three text files that exist that haven't been modified in over 100 days: ... (3 Replies)
Discussion started by: jwperry
3 Replies

2. UNIX for Dummies Questions & Answers

How do I ignore certain dir while using find? solved.

Hello everyone, I'm a newbie. I've got a problem while using find. I know there is a way to do it in man find which is something like find . -wholename './src/emacs' -prune -o -print it works but i also want to use -daystart, -mtime, -type on it and i dont know whats the sequence of these... (0 Replies)
Discussion started by: aquaraider
0 Replies

3. UNIX for Dummies Questions & Answers

find lines in file1.txt not found in file2.txt memory problem

I have a diff command that does what I want but when comparing large text/log files, it uses up all the memory I have (sometimes over 8gig of memory) diff file1.txt file2.txt | grep '^<'| awk '{$1="";print $0}' | sed 's/^ *//' Is there a better more efficient way to find the lines in one file... (5 Replies)
Discussion started by: raptor25
5 Replies

4. Shell Programming and Scripting

Find: ignore directory completely

Hello, I know find can be prevented from recursing into directories with something like the following... find . -name .svn -prune -a type d But how can I completely prevent directories of a certain name (.svn) from being displayed at all, the top level and the children? I really... (2 Replies)
Discussion started by: nwb123
2 Replies

5. Shell Programming and Scripting

Find command with ignore directory

Dear All, I am using find command find /my_rep/*/RKYPROOF/*/*/WDM/HOME_INT/PWD_DATA -name rk*myguidelines*.pdf -print The problem i am facing here is find /my_rep/*/ the directory after my_rep could be mice001, mice002 and mice001_PO, mice002_PO i want to ignore mice***_PO directory... (3 Replies)
Discussion started by: yadavricky
3 Replies

6. SCO

Grep to ignore suffix & find end of line

In COBOL, a hyphen can be used in a field name and in a specific program some field names would be identical to others except a suffix was added--sometimes a suffix to a suffix was used. For example, assume I am looking for AAA, AAA-BBB, and AAA-BBB-CCC and don't want to look at AAA-BBB-CCC... (7 Replies)
Discussion started by: wbport
7 Replies

7. UNIX for Beginners Questions & Answers

Find command with Ignore Access issues

Hi, I am using following command to find a specific file. find . -name "find*.txt" -type f -print I am issuing that command at root directory since I don't know in which sub folder that file is getting created from some other process. As I am not having access to all directories, my... (3 Replies)
Discussion started by: RameshCh
3 Replies

8. Shell Programming and Scripting

Awk, sed, shell all words in INPUT.txt find in column1 of TABLE.txt and replce with column2 in

Hi dears i have text file like this: INPUT.txt 001_1_173 j nuh ]az 001_1_174 j ]esma. nuh ]/.xori . . . and have another text like this TABLE.txt j j nuh word1... (6 Replies)
Discussion started by: alii
6 Replies

9. Shell Programming and Scripting

Script using awk to find and replace a line, how to ignore comment lines

Hello, I have some code that works more or less. This is called by a make file to adjust some hard-coded definitions in the src code. The script generated some values by looking at some of the src files and then writes those values to specific locations in other files. The awk code is used to... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

10. UNIX for Advanced & Expert Users

AIX find ignore directory

I am using aix. I would like to ignore the /u directory. I tried this but it is not working. find / -type f -type d \( -path /u \) -prune -o -name '*rpm*' 2>/dev/null /u/appx/ls.rpm /u/arch/vim.rpm (4 Replies)
Discussion started by: cokedude
4 Replies
FNMATCH(3)						     Linux Programmer's Manual							FNMATCH(3)

NAME
fnmatch - match filename or pathname SYNOPSIS
#include <fnmatch.h> int fnmatch(const char *pattern, const char *string, int flags); DESCRIPTION
The fnmatch() function checks whether the string argument matches the pattern argument, which is a shell wildcard pattern. The flags argument modifies the behavior; it is the bitwise OR of zero or more of the following flags: FNM_NOESCAPE If this flag is set, treat backslash as an ordinary character, instead of an escape character. FNM_PATHNAME If this flag is set, match a slash in string only with a slash in pattern and not by an asterisk (*) or a question mark (?) metacharacter, nor by a bracket expression ([]) containing a slash. FNM_PERIOD If this flag is set, a leading period in string has to be matched exactly by a period in pattern. A period is considered to be leading if it is the first character in string, or if both FNM_PATHNAME is set and the period immediately follows a slash. FNM_FILE_NAME This is a GNU synonym for FNM_PATHNAME. FNM_LEADING_DIR If this flag (a GNU extension) is set, the pattern is considered to be matched if it matches an initial segment of string which is followed by a slash. This flag is mainly for the internal use of glibc and is implemented only in certain cases. FNM_CASEFOLD If this flag (a GNU extension) is set, the pattern is matched case-insensitively. FNM_EXTMATCH If this flag (a GNU extension) is set, extended patterns are supported, as introduced by 'ksh' and now supported by other shells. The extended format is as follows, with pattern-list being a '|' separated list of patterns. '?(pattern-list)' The pattern matches if zero or one occurrences of any of the patterns in the pattern-list match the input string. '*(pattern-list)' The pattern matches if zero or more occurrences of any of the patterns in the pattern-list match the input string. '+(pattern-list)' The pattern matches if one or more occurrences of any of the patterns in the pattern-list match the input string. '@(pattern-list)' The pattern matches if exactly one occurrence of any of the patterns in the pattern-list match the input string. '!(pattern-list)' The pattern matches if the input string cannot be matched with any of the patterns in the pattern-list. RETURN VALUE
Zero if string matches pattern, FNM_NOMATCH if there is no match or another nonzero value if there is an error. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +----------+---------------+--------------------+ |Interface | Attribute | Value | +----------+---------------+--------------------+ |fnmatch() | Thread safety | MT-Safe env locale | +----------+---------------+--------------------+ CONFORMING TO
POSIX.1-2001, POSIX.1-2008, POSIX.2. The FNM_FILE_NAME, FNM_LEADING_DIR, and FNM_CASEFOLD flags are GNU extensions. SEE ALSO
sh(1), glob(3), scandir(3), wordexp(3), glob(7) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. GNU
2015-12-28 FNMATCH(3)
All times are GMT -4. The time now is 07:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy