Sponsored Content
Top Forums Shell Programming and Scripting Find command excluding directories and some files Post 302991006 by jim mcnamara on Sunday 5th of February 2017 09:14:55 AM
Old 02-05-2017
What the script does is hard to see. But.
Consider that sometimes using a tool for a complex task sometimes requires other tools.

As a template:

Code:
find path1 path2 path3 | grep -v '^\.*'

Which removes so-called hidden files - ones starting the dot character. They are hidden because the default for ls is not to display them. ls -a will display them.

If you have a "crazy" list of filenames to ignore - one that has too many names - use a pattern file with grep.

Code:
find path1 path2 path3 | grep -f pattern_file -v

Where pattern_file looks like:
Code:
.direct*
.X*
.x*

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

find excluding the hidden files

Hi , I am trying to use the find command with delete in a directory . Even though i use a wil character search the find command is checking the hidden files which inturn results in error . Can i avoid look that into the hidden files ?? I am using HP unix . find /cv1/ -name "ite*"... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

2. UNIX for Dummies Questions & Answers

Find Files in a Directory Excluding Subdirectories

Hi, I have a filename Location.txt in a directory /abc. Similar name file is present in its subdirectory /abc/xyz. I want to find the file which is present only in /abc and not in /abc/xyz. Please any1 of u can provide a quick suggestion. Its very urgent. Thanks, Amol (2 Replies)
Discussion started by: Amol_Dicholkar
2 Replies

3. UNIX for Dummies Questions & Answers

Excluding directories with find

How do I exclude directories with the find command on Solaris? I want to skip the directories /proc and /shared. find / -nouser -print This shows me all files and directories that don't have an owner but I need to skip /shared and /proc. I've been able to get it to work on Linux... (3 Replies)
Discussion started by: x96riley3
3 Replies

4. UNIX for Dummies Questions & Answers

Copy Directories excluding files

Hi guys, I want to copy folder and sub folders only. I don't want the files. If i use cp -r command it will copy entirely with files. Could any one suggest me. Thanks in advance (1 Reply)
Discussion started by: karthik82
1 Replies

5. UNIX for Dummies Questions & Answers

List directories and sub directories recursively excluding files

Hi, Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process. I wanted to disply using a unix command all the directories recursively excluding files. I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies

6. AIX

find command to list all the 777 files and directories owned by root user

Hi I'm logged in to an AIX box now and we need to do an audit on this box. cbssapr01:# pwd / Which command will show all the files and directories owned by root user with permissions as 777 ? (8 Replies)
Discussion started by: newtoaixos
8 Replies

7. Shell Programming and Scripting

Copy files/directories excluding multiple paterns

my directory structure is like below: basedir\ p.txt q.htm r.java b\ abc.htm xyz.java c\ p.htm q.java rst.txt my requirement is i want to copy all the files and directories... (0 Replies)
Discussion started by: ajayyadavmca
0 Replies

8. Shell Programming and Scripting

Excluding directories from a find

I've looked at a few similar threads, but I can't bridge from those examples to what I'm working on, so I'm hoping someone can help. I want to extend the following statement find $PathToCheck -type f \( -not -iwholename "$ScriptDir/*" \) -exec md5sum "{}" \;>$NewSigs to exclude several... (9 Replies)
Discussion started by: nixie
9 Replies

9. Shell Programming and Scripting

Find command to search files in a directory excluding subdirectories

Hi Forum, I am using the below command to find files older than x days in a directory excluding subdirectories. From the previous forums I got to know that prune command helps us not to descend in subdirectories. Though I am using it here, not getting the desired result. cd $dir... (8 Replies)
Discussion started by: jhilmil
8 Replies

10. UNIX for Advanced & Expert Users

Find all files in the current directory excluding hidden files and directories

Find all files in the current directory only excluding hidden directories and files. For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided. `find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Discussion started by: ksailesh1
7 Replies
link(2) 							System Calls Manual							   link(2)

NAME
link - Creates a hard link to an existing file on the local file system SYNOPSIS
#include <unistd.h> int link ( const char *path1, const char *path2 ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: link(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the pathname of an existing file. Points to the pathname for the directory entry to be created. If the path2 parameter names a symbolic link, an error is returned. DESCRIPTION
The link() function creates an additional hard link (directory entry) for an existing file. The old and the new link share equal access rights to the underlying object. The link() function atomically creates a new link for the existing file and increments the link count of the file by one. Both the path1 and path2 parameters must reside on the same file system. A hard link to a directory cannot be created. Upon successful completion, the link() function marks the st_ctime field of the file for update, and marks the st_ctime and st_mtime fields of the directory containing the new entry for update. A process must have write permission in the target directory with respect to all access control policies configured on the system. See symlink(2) for information about making symbolic links, including Context Dependent Symbolic Links (CDSLs). RETURN VALUES
Upon successful completion, the link() function returns a value of 0 (zero). If the link() function fails, a value of -1 is returned, no link is created, and errno is set to indicate the error. ERRORS
If the link() function fails, errno may be set to one of the following values: The requested link requires writing in a directory with a mode that denies write permission, or a component of either the path1 or path2 parameter denies search permission. The requested link requires writing in a directory to which the process does not have write access with respect to one or more of the system's configured access policies. The directory in which the entry for the new link is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. The link named by the path2 parameter already exists. The path1 or path2 parameter is an invalid address. [Tru64 UNIX] An I/O error occurred when updating the directory. Too many links were encountered in translating path1 or path2. The number of links to the file named by path1 would exceed LINK_MAX. The length of the path1 or path2 string exceeds PATH_MAX or a pathname component is longer than NAME_MAX. The file named by the path1 parameter does not exist or the path1 or path2 parameter is an empty string. The directory in which the entry for the new link is being placed cannot be extended because there is no space left on the file system containing the directory. A component of either path prefix is not a directory. The file named by the path1 parameter is a directory. The requested link requires writing in a directory on a read-only file system. The link named by the path2 parameter and the file named by the path1 parameter are on different file systems. [Tru64 UNIX] For NFS file access, if the link() function fails, errno may also be set to one of the following values: Indicates that the system file table is full or there are too many files currently open in the system. Indicates a stale NFS file handle. An opened file was deleted by the server or another client; a client cannot open a file because the server has unmounted or unexported the remote directory; or the directory that contains an opened file was unmounted or unexported by the server. RELATED INFORMATION
Commands: link(1), unlink(1) Functions: unlink(2), symlink(2) Standards: standards(5) delim off link(2)
All times are GMT -4. The time now is 11:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy