Hello friends,
I am writing a simple shell script which will copy one particular type of files to backup folder if files exists. If files doesn't exists, mv command should not be executed.
My file pattern is like wcm-spider-maestro.log.2009-07-15, wcm-spider-maestro.log.2009-07-16 etc..
I... (6 Replies)
cp $PATHLOGS/$DATE/*.* $TMP/logs_tmp/
cp $PATHLOGS/$DATE1/*.* $TMP/logs_tmp/
Before copying the files I have to check if the directory $DATE1 and $DATE2 exists.
If directory exists then, check if the folder contains some files.
if the file exists then, check if the file size is greater... (3 Replies)
Hi,
I have two files say xxx.txt and yyy.txt. xxx.txt is with list of patterns within double quotes. Eg.
"this is the line1"
"this is the line2"
The yyy.txt with lot of lines. eg:
"This is a test message which contains rubbish information just to fill the page which is of no use. this is... (3 Replies)
I want to perform SQL *Loader operation only if a file named "load.txt" exists in a directory "/home/loc/etc". Please help how to check this with a if condition. (8 Replies)
Hi ! All
I just want to search and write to new file if pattern is found in text file
following are my text files by which I want to search Month and last column number
my text file1
15-Jan-2011 25 ARTS 1255 125 125 178 198
15-Jan-2011 25 ARTS 1255 125 125 178 198
15-Jan-2011 25... (3 Replies)
Hi Gurus,
I have a requests to find if all the file in the filelist exist in certain directory.
example:
my filelist
abc
def
ddd
cde
afg
how can I find these 5 files exists at director /home/abc
Thanks in advance (7 Replies)
Hi guys,
I am beginner trying to learn unix. So any help is welcomed.
My requirement is to check whether is a file exists in a particular directory or not.
The directory path and filename are taken dynamically with user interaction. So the program should continue only if the $filename... (1 Reply)
I have many files that can have various amounts of rows. I essentially want to output each row into a new file if a pattern is matched between two files.
I have some code that does something similar but I want it to output every single input row from every file into a separate output file; that... (5 Replies)
Hi experts,
I have two arrays one has the file paths to be searched in , and the other has the files to be serached.For eg
searchfile.dat will have
abc303
xyz123
i have to search for files that could be abc303*.dat or for that matter any extension . abc303*.dat.gz
The following code... (2 Replies)
There are some files with suffix dates like abc_20032019.dat abc_17032019.dat
If at least one file exists then perform some operation else exit from execution.
Korn shell
----------------------------------
array=($inputdir/abc*.dat)
If ] ]
then
echo " file exits"
else
echo " file does... (10 Replies)
Discussion started by: Rajesh123
10 Replies
LEARN ABOUT PHP
clearstatcache
CLEARSTATCACHE(3) 1 CLEARSTATCACHE(3)clearstatcache - Clears file status cacheSYNOPSIS
void clearstatcache ([bool $clear_realpath_cache = false], [string $filename])
DESCRIPTION
When you use stat(3), lstat(3), or any of the other functions listed in the affected functions list (below), PHP caches the information
those functions return in order to provide faster performance. However, in certain cases, you may want to clear the cached information. For
instance, if the same file is being checked multiple times within a single script, and that file is in danger of being removed or changed
during that script's operation, you may elect to clear the status cache. In these cases, you can use the clearstatcache(3) function to
clear the information that PHP caches about a file.
You should also note that PHP doesn't cache information about non-existent files. So, if you call file_exists(3) on a file that doesn't
exist, it will return FALSE until you create the file. If you create the file, it will return TRUE even if you then delete the file. How-
ever unlink(3) clears the cache automatically.
Note
This function caches information about specific filenames, so you only need to call clearstatcache(3) if you are performing multi-
ple operations on the same filename and require the information about that particular file to not be cached.
Affected functions include stat(3), lstat(3), file_exists(3), is_writable(3), is_readable(3), is_executable(3), is_file(3), is_dir(3),
is_link(3), filectime(3), fileatime(3), filemtime(3), fileinode(3), filegroup(3), fileowner(3), filesize(3), filetype(3), and fileperms(3).
PARAMETERS
o $clear_realpath_cache
- Whether to clear the realpath cache or not.
o $filename
- Clear the realpath and the stat cache for a specific filename only; only used if $clear_realpath_cache is TRUE.
RETURN VALUES
No value is returned.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.0 | |
| | |
| | Added optional $clear_realpath_cache and $file- |
| | name parameters. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
clearstatcache(3) example
<?php
$file = 'output_log.txt';
function get_owner($file)
{
$stat = stat($file);
$user = posix_getpwuid($stat['uid']);
return $user['name'];
}
$format = "UID @ %s: %s
";
printf($format, date('r'), get_owner($file));
chown($file, 'ross');
printf($format, date('r'), get_owner($file));
clearstatcache();
printf($format, date('r'), get_owner($file));
?>
The above example will output something similar to:
UID @ Sun, 12 Oct 2008 20:48:28 +0100: root
UID @ Sun, 12 Oct 2008 20:48:28 +0100: root
UID @ Sun, 12 Oct 2008 20:48:28 +0100: ross
PHP Documentation Group CLEARSTATCACHE(3)