hi, I have a list of filenames and I want to verify if they all exist. I know "if filename" would do the trick but how do I go about a list of files? thanks (3 Replies)
Hi ,
I have a script wherein i have a For Loop.
Within this for loop i create a variable and assign it a value.
The script goes to a For Loop only if certain conditions are met , which means the variable may or may not exists.
However down the line in the script i have to check if that... (2 Replies)
Hi everybody,
I need to check in C program wether a given login is known on the system. Is there any system function that could do this ?
So far, all I could find is getpwnam(), which answers my problem by parsing the local password database. But won't work if a user is authenticated by... (10 Replies)
Hello
I am having a requirement like if there is no file in the directory then i need a message to pop on after the execution of the script.
My script basically does for File in `ls -t $DIRECTORY | tail -1`;
if there is no file the DIRECTORY then the script is simply exiting with out... (2 Replies)
Hi,
I have a directory with possibly around 800,000 files in it.
What is the fastest way to list file(s) in this directory with a wildcard.
for example would
ls -1 *.abcdefg.Z
or
find . -name "*.abcdefg.Z"
be the fastest way to find all of the files that end with .abcdefg.Z... (6 Replies)
I have requirement where i need to search for files which start with SALESORDER and PURCHASEORDER. i need to process the files with SALESORDER first and then PURCHASEORDER. If SALESORDER files are not there i dont want to process PURCHASEORDER and i want to come out of script. I have written a code... (4 Replies)
i want to check if the file is in the directory or not, and also it should be handle error conditions, like missing files and report the error and exit.
i did something like this:
file ="hello"
if !test -e "${file}"
then echo "No such files exist!"
exit 1
else
do something.......
fi
... (1 Reply)
Hi I am having a problem to verify existence of files. I need to know whether or not files in a folder that begins with a name.
For example all files that start with The_File_ *.
I was doing it this way, but gives me error.
if text -f /work/The_File_*
then
...
else
..
fi (5 Replies)
Hi
I have a requirement to check whether the files exists, then it will call other steps in shell script.
I did
ls *.csv|wc -l
if
then checking the count of the files should be more than 1 then it will call other steps.
I am getting the error that too many arguements as there n... (13 Replies)
hi
i wanted to check if the file exist or not(multiple files)
DIRE=/home/V478
if ;
then
echo "file present"
else
echo "file not present"
fi
But i am getting the error as
: [: unexpected operator/operand (3 Replies)
Discussion started by: ATWC
3 Replies
LEARN ABOUT BSD
seekdir
DIRECTORY(3) Library Functions Manual DIRECTORY(3)NAME
opendir, readdir, telldir, seekdir, rewinddir, closedir - directory operations
SYNOPSIS
#include <sys/types.h>
#include <sys/dir.h>
DIR *opendir(filename)
char *filename;
struct direct *readdir(dirp)
DIR *dirp;
long telldir(dirp)
DIR *dirp;
seekdir(dirp, loc)
DIR *dirp;
long loc;
rewinddir(dirp)
DIR *dirp;
closedir(dirp)
DIR *dirp;
DESCRIPTION
Opendir opens the directory named by filename and associates a directory stream with it. Opendir returns a pointer to be used to identify
the directory stream in subsequent operations. The pointer NULL is returned if filename cannot be accessed, or if it cannot malloc(3)
enough memory to hold the whole thing.
Readdir returns a pointer to the next directory entry. It returns NULL upon reaching the end of the directory or detecting an invalid
seekdir operation.
Telldir returns the current location associated with the named directory stream.
Seekdir sets the position of the next readdir operation on the directory stream. The new position reverts to the one associated with the
directory stream when the telldir operation was performed. Values returned by telldir are good only for the lifetime of the DIR pointer
from which they are derived. If the directory is closed and then reopened, the telldir value may be invalidated due to undetected direc-
tory compaction. It is safe to use a previous telldir value immediately after a call to opendir and before any calls to readdir.
Rewinddir resets the position of the named directory stream to the beginning of the directory.
Closedir closes the named directory stream and frees the structure associated with the DIR pointer.
Sample code which searchs a directory for entry ``name'' is:
len = strlen(name);
dirp = opendir(".");
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
if (dp->d_namlen == len && !strcmp(dp->d_name, name)) {
closedir(dirp);
return FOUND;
}
closedir(dirp);
return NOT_FOUND;
SEE ALSO open(2), close(2), read(2), lseek(2), dir(5)4.2 Berkeley Distribution September 24, 1985 DIRECTORY(3)