@abinaya
sorry, yes i did try your solution and im afraid i couldnt get it to work either
These are two methods which are very close but still dont work, any other ideas
this script does not wait for the user input example output looks like
spaceDir/ 234.txt remove space (Y/N)
input not regonised
spaceDir/12 34.txt remove space (Y/N)
input not regonised
This method waits for the user input but does not print out the file correctly e.g
spaceDir/file remove spaces(Y/N): y
mv: cannot access spaceDir/file
spaceDir/name remove spaces(Y/N): y
mv: cannot access spaceDir/name
I cannot seem to pass the value of the variable assigned in the "else" statment below to an "if" statement outside of the loop. When I debug using "set -x", I find that the value of "$A" is empty. Is there something I'm missing here? Code is below:
do
if ] then
echo "Good Match"... (2 Replies)
I have the following statement in script:
find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN2} -print | while read file; do
...
done
When there are no files located by the find comand it returns:
"find: bad status-- /home/rnitcher/test/....." to the command line
How do I get control in... (3 Replies)
Hi,
I have a strange problem and I'm sure its because I'm doing something stupid.
When I loop through all of the files in a directory they cannot be found.
Any help would be greatly appreciated.
Thanks,
-E
$ touch a.txt
$ touch b.txt
$ ls
a.txt b.txt
$ for f in `ls` ; do... (3 Replies)
Hi frnd , hv nice week ahead,
in shell script i found 2 words as below
1 ) targ_found=`sed -n \`echo $line_no\`p sesslog.txt | grep -ic 'Targ Rowid'`
2 ) bracket_found=`sed -n \`echo $line_no\`p sesslog.txt | grep -wc ')'`
now we got he line number of 2 words. now i want to... (1 Reply)
hi ,
I have certain files at the same path with differeent extensions like .dat , .txt etc ...........i need to rename them with extension .found at the same path with the help of loop....
also the files names will be like this ;
abc_2010_c1.dat
abc_2010_c2.dat
xyz_2010_c1.txt (2 Replies)
Hi All,
I have a simple script.sh file. It gives me " file.txt' for reading (no such file or directory)" Why can this happen?
%ls
ch1file.txt ch2file.txt ch3file.txt
% chmod +x script.sh
% bash
% ./script.sh
where script.sh is as follows
for i in seq(3)
do awk '{print $1}'... (1 Reply)
can any1 please tell me what is problem with following code:
i=1;
cat test| while read CMD;
do
Var$i=$CMD; or Var$i=$(echo $CMD) ;
let i++
doneI keep getting error :
line 4: Var1=sometext: command not found (2 Replies)
I am unable to use the value of a variable.
while ]
do
LstFldDataPart =`head -n "$LstFldDataPartCntr" "${FeedFileDir}/${FeedFileBadRecs}" | tail -1 | tr -d '\n'`
echo $LstFldDataPart
JndLstFldDataPart="${JndLstFldDataPart}${LstFldDataPart}"
LstFldDataPartCntr=... (3 Replies)
Hi, I have a control file which will contain all filenames(300) files. Loop through all the file names in the control files and check the existence of this file in another directory(same server). I need to infinitely(2 hrs) run this while loop until all the files are found. Once a file is found,... (5 Replies)
Dear Help,
Is it possible to continue the loop by going to the next available value, if the 'expected value' is not found. I have a list of values which might not get incremented by fixed value and hence the loop could break and the script could terminate.
Any suggestion is appreciated.
... (1 Reply)
Discussion started by: Indra2011
1 Replies
LEARN ABOUT PHP
dir
DIR(3) 1 DIR(3)dir - Return an instance of the Directory classSYNOPSIS
Directory dir (string $directory, [resource $context])
DESCRIPTION
A pseudo-object oriented mechanism for reading a directory. The given $directory is opened.
PARAMETERS
o $directory
- Directory to open
o $context
-
Note
Context support was added with PHP 5.0.0. For a description of contexts, refer to "Streams".
RETURN VALUES
Returns an instance of Directory, or NULL with wrong parameters, or FALSE in case of another error.
EXAMPLES
Example #1
dir(3) example
Please note the fashion in which Directory.read(3)'s return value is checked in the example below. We are explicitly testing
whether the return value is identical to (equal to and of the same type as - see Comparison Operators for more information) FALSE
since otherwise, any directory entry whose name evaluates to FALSE will stop the loop.
<?php
$d = dir("/etc/php5");
echo "Handle: " . $d->handle . "
";
echo "Path: " . $d->path . "
";
while (false !== ($entry = $d->read())) {
echo $entry."
";
}
$d->close();
?>
The above example will output something similar to:
Handle: Resource id #2
Path: /etc/php5
apache
cgi
cli
NOTES
Note
The order in which directory entries are returned by the read method is system-dependent.
PHP Documentation Group DIR(3)