using find but avoiding sparse files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using find but avoiding sparse files
# 1  
Old 07-25-2011
using find but avoiding sparse files

I am no Unix administrator...I live in windows land.

I wrote a script to find files of certain names and process them but was later advised to avoid checking sparse files since it would use up a lot of resources and the files I was looking for were not there.

How do I avoid doing the find on the sparse files?

shellfun
# 2  
Old 07-25-2011
Assuming you mean that you wish not to search given branches of the directory tree, from "man find"
Code:
-path pattern
              File name matches shell pattern pattern.  The metacharacters do not treat `/' or `.' specially; so, for example,
                        find . -path "./sr*sc"
              will  print an entry for a directory called `./src/misc' (if one exists).  To ignore a whole directory tree, use -prune 
              rather than checking every file in the tree.  For example, to skip the directory `src/emacs' and all files and directories 
              under it, and print the names of the other files found, do something  like this:
                        find . -path ./src/emacs -prune -o -print
              Note that the pattern match test applies to the whole file name, starting from one of the start points named on the 
              command line.  It would only make sense to use an absolute path name here if the relevant start point is also an 
              absolute path.  This means that this command will never match anything:
                        find bar -path /foo/bar/myfile -print
              The predicate -path is also supported by HP-UX find and will be in a forthcoming version of the POSIX standard.

# 3  
Old 07-25-2011
thanks....I get/got the skipping directories part but I will not know what those directories or files are ahead of time. There a many dozens of servers.

Is there a naming standard for sparse files? As a non-admin how do I know what is sparse?
# 4  
Old 08-04-2011
bump?

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Avoiding some files inside a loop

In my script I need to loop around some files like below example files are fa.info.abcd fa.info.bxde fa.info.cdas ------ for test_data in fa.info.* do # Some text appending logic applied # Copy to another directory done Now I need to discard some files while looping around ... (9 Replies)
Discussion started by: smile689
9 Replies

2. Shell Programming and Scripting

Help to find length of string avoiding trailing spaces

Hi, I have a record of length 200 bytes and values filled is only 100 bytes and remaining 100 spaces is occupied by spaces. In script wen i try to find the length of the entire record it should get as 200 not 100. i tried using length and wc -c but it doesnt work can anyone have any idea on... (3 Replies)
Discussion started by: Pranaveen
3 Replies

3. Programming

C Data Structure to represent a Sparse Array

Which data structure will be most appropriate to represent a sparse array? (1 Reply)
Discussion started by: rupeshkp728
1 Replies

4. UNIX for Dummies Questions & Answers

Avoiding the history

In bash shell, how we can avoid the commands getting recorded in history file. One way i can think of is : export HISTSIZE=0 Is there any other way to achieve this? Thanks (1 Reply)
Discussion started by: pandeesh
1 Replies

5. UNIX for Dummies Questions & Answers

Avoiding the second run of the script

Hi all, I want to put a check in my script to check if the same instance is already running and not finished and if not then does not allow it to run! in which part of my script I should put this? and any idea how I should write it? tx (4 Replies)
Discussion started by: messi777
4 Replies

6. Shell Programming and Scripting

Convert a matrix to sparse representation

Hi All, I have a matrix stored in a file matrix.mtx and looks like this: 1 0.5 0.33 0.25 0 0.33 0.25 0.2 0 0 0 0.16 0 0 0 0.14 I want to convert this matrix to its sparse representation like the one give below (sparse_matrix.mtx). This means that above matrix has been converted to its... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

7. Programming

locate holes in a sparse file.

Lets say my program reads one block (4096 bytes) at a time from a file. It needs to report whether that block is a hole. The program currently uses read() to read 1 block into a 4KB buffer. Now I know that even if that block is a hole, it will be replaced by a sequence of NULL bytes '\0'... (15 Replies)
Discussion started by: tantric
15 Replies

8. UNIX for Advanced & Expert Users

sparse files

what are sparse files? (2 Replies)
Discussion started by: areef4u
2 Replies
Login or Register to Ask a Question