Sponsored Content
Top Forums Shell Programming and Scripting How to process only new files Post 302127275 by Ygor on Tuesday 17th of July 2007 04:52:42 AM
Old 07-17-2007
Method 1: use find -newer and a reference file.
Code:
find . -type f -newer ref_file -print |\
while read filename
do
    :  something with $filename
done
touch ref_file

Method 2: check that you haven't processed the file before.
Code:
set -- *
for filename
do
    if ! grep -q $filename ref_file
    then
        :  something with $filename
        echo $filename >> ref_file
    fi
done

Combine methods if necessary.
 

10 More Discussions You Might Find Interesting

1. HP-UX

How to get the opened files by a process

Hi, i'd like to get the files which are opened by a process during his execution using the c language. Thanks for helping me. (2 Replies)
Discussion started by: benoit.gaillard
2 Replies

2. Shell Programming and Scripting

How to process the files using .tar.gz files in script

Hi, I have some file in /users/xyz directoty with .tar.gz extension. i need to find these files and if found in need to run other commands. I now the command for finding files,but how to put if condition ?please help me Thanks (3 Replies)
Discussion started by: bmkreddy
3 Replies

3. UNIX for Dummies Questions & Answers

How do I Process Multiple Files

Hi, First post here. In Mac OSX terminal I need to run a program against multiple files in a directory and append the output to tab separated variable file. I currently type the following to process just one file MBP:/Users/dc1743/Desktop/SFT root# ./myprogram myfile1.plist >>... (1 Reply)
Discussion started by: dc1743
1 Replies

4. Solaris

files asscciated with a particular process

if i am finding out that a process has a more cpu usage before killing the process what are the commands to find out the files which are used by the process. can anyone help this thanks (1 Reply)
Discussion started by: sureshlee_83
1 Replies

5. Shell Programming and Scripting

not able to process files

hi i have a dir contains files i am reading ls $path | while read FILE do grep "a GFT buffer" $path/$FILE ...... ..... done it is able to process the fist file, from secomd onwards it is giving the following error, 2nd file name is "sd_gfts_GFT1_TCPGFT.trc.4" grep:... (1 Reply)
Discussion started by: Satyak
1 Replies

6. OS X (Apple)

Open Files for a process

I am having a client/server application which will download files from server. If server has directories, it will create directories/sub directories and then download files. In this process, I observed that number of open files are more than 400 (which is approxmately same as number of dir/subdir... (1 Reply)
Discussion started by: satyam90
1 Replies

7. UNIX for Dummies Questions & Answers

Find the process and their files

Hi all, when i run a program in a Linux, it may call bunch of other files. How do i find those files? thanks in adanvance Sajith (1 Reply)
Discussion started by: email2sajith
1 Replies

8. Shell Programming and Scripting

Loop to process 2 files with same name in different path

Hello forum members, I hope you can help me with this I don't know hot to reach. I have a list of files in "/home/MyPath1/" and in "/home/MyPath2/". The files have the same name in both folders. (but different content, the content doesn't matter here I think) /home/MyPath1/ filename1.txt... (4 Replies)
Discussion started by: Ophiuchus
4 Replies

9. Shell Programming and Scripting

What is the correct way to process files

Is there a general way I can use so as to process paths/files from your terminal without the need to backslash things? Till recently I used to use touch "file_here" but it does not work if file_here contains any of the characters ` and ", I still need to backslash them if I want to make the... (1 Reply)
Discussion started by: hakermania
1 Replies

10. Red Hat

Process to use open files

I would like to test open files usage in my system, if I want to create a process ( or script ) that can use a certain amount ( eg. 1000 ) of open files , is it possible to create such process ( or script ) ? (3 Replies)
Discussion started by: ust
3 Replies
fileutil(n)							  file utilities						       fileutil(n)

NAME
fileutil - Procedures implementing some file utilities SYNOPSIS
package require Tcl 8 package require fileutil ?1.4? ::fileutil::cat filename ::fileutil::fileType filename ::fileutil::find ?basedir ?filtercmd?? ::fileutil::findByPattern basedir ?-regexp|-glob? ?--? patterns ::fileutil::foreachLine var filename cmd ::fileutil::grep pattern ?files? ::fileutil::stripN path n ::fileutil::stripPwd path ::fileutil::touch ?-a? ?-c? ?-m? ?-r ref_file? ?-t time? filename ?...? DESCRIPTION
This package provides implementations of standard unix utilities. ::fileutil::cat filename A tcl implementation of the UNIX cat command. Returns the contents of the specified file. The first argument is the name of the file to read. ::fileutil::fileType filename An implementation of the UNIX file command, which uses various heuristics to guess the type of a file. Returns a list specifying as much type information as can be determined about the file, from most general (eg, "binary" or "text") to most specific (eg, "gif"). For example, the return value for a GIF file would be "binary graphic gif". The command will detect the following types of files: directory, empty, binary, text, script (with interpreter), executable elf, graphic gif, graphic jpeg, html, xml (with doctype if available), message pgp, and link. ::fileutil::find ?basedir ?filtercmd?? An implementation of the unix command find. Adapted from the Tcler's Wiki. Takes at most two arguments, the path to the directory to start searching from and a command to use to evaluate interest in each file. The path defaults to ".", i.e. the current directory. The command defaults to the empty string, which means that all files are of interest. The command takes care not to loose itself in infinite loops upon encountering circular link structures. The result of the command is a list containing the paths to the inter- esting files. ::fileutil::findByPattern basedir ?-regexp|-glob? ?--? patterns This command is based upon the TclX command recursive_glob, except that it doesn't allow recursion over more than one directory at a time. It uses ::fileutil::find internally and is thus able to and does follow symbolic links, something the TclX command does not do. First argument is the directory to start the search in, second argument is a list of patterns. The command returns a list of all files reachable through basedir whose names match at least one of the patterns. The options before the pattern-list determine the style of matching, either regexp or glob. glob-style matching is the default if no options are given. Usage of the option -- stops option processing. This allows the use of a leading '-' in the patterns. ::fileutil::foreachLine var filename cmd The command reads the file filename and executes the script cmd for every line in the file. During the execution of the script the variable var is set to the contents of the current line. The return value of this command is the result of the last invocation of the script cmd or the empty string if the file was empty. ::fileutil::grep pattern ?files? Implementation of grep. Adapted from the Tcler's Wiki. The first argument defines the pattern to search for. This is followed by a list of files to search through. The list is optional and stdin will be used if it is missing. The result of the procedures is a list containing the matches. Each match is a single element of the list and contains filename, number and contents of the matching line, separated by a colons. ::fileutil::stripN path n Removes the first n elements from the specified path and returns the modified path. If n is greater than the number of components in path an empty string is returned. ::fileutil::stripPwd path If the path is inside of the directory returned by [pwd] it is made relative to that directory. In other words, the current working directory is stripped from the path. The possibly modified path is returned as the result of the command. ::fileutil::touch ?-a? ?-c? ?-m? ?-r ref_file? ?-t time? filename ?...? Implementation of touch. Alter the atime and mtime of the specified files. If -c, do not create files if they do not already exist. If -r, use the atime and mtime from ref_file. If -t, use the integer clock value time. It is illegal to specify both -r and -t. If -a, only change the atime. If -m, only change the mtime. KEYWORDS
file utilities fileutil 1.4 fileutil(n)
All times are GMT -4. The time now is 04:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy