If you are running a Perl script there is no need to spawn a shell to do this, Perl has a number of ways (as always) of doing this, you can use a glob to get the values
Or you could open the directory and read the contents.
The glob is obviously easier to use, however if you need to do more complex processing than just printing the filenames the opendir, readdir , closedir approach gives you more flexibility.
FOR: Windows NT 4
I want perl to read a directory. there is suposed to be two files in the folder ( file1.ini and file2.ini ) and i want perl to print "Files present" or "Files NOT present" to a text document ( report.txt )
how do i do it.? (2 Replies)
At the moment I do not know anything UNIX script :rolleyes:
but i need to make script that prints the content of the archives
(of text) that are deposited in a directory and Later erases these
archives, leaving the directory emptiness
It would be like repository for print
please... (9 Replies)
Hi all,
I have the following question. Considder that in the directory /code the script remove.pl exists. What i want is to run this script and remove some files that exist in the directory /dir/tmp. I use the below code but it does not work.
system("cd /dir/code");
system("rm FileName");
... (6 Replies)
Suppose u have two files
one file
>hi|23433|sp|he is RAJ<space>>hi|23333|df|He is HUMAN<space>>hi|222|gi|howru|just
WOWHEISWONDERFUL
>hi|25559|gs|heisANUJ<space>>hi|2232|sp|he is fool
SKSIKSIKSLKSSLLS
Another file
HUMAN
so output wil be ...if the list contain HUMAN only take it... (1 Reply)
Hi I have this code to print the current directory using Perl
use Cwd qw(abs_path);
my $path = abs_path($0);
print "$path\n";
But it is displaying my perl source code file along with the directory.
like this
C:\Perl\duration.pl
But I want it only to display this... (1 Reply)
Hello All
I am implementing my task in Perl and i found an issue.
What i want to do is to remove files from the directory which were made 20 days back using Perl script (9 Replies)
Hi All,
I have written one program to print the files which are not updated in the specified directory in .Dat file. If I am executing the same command in the command prompt its working fine but if I am executing in shell script it's not working fine. Please correct if any thing wrong in the... (3 Replies)
Given a directory containing say a few thousand files,
please output a list of all the names of the files in the directory that are exactly the same, i.e. have the same contents.
func(a_directory_name) output -> {“matches”: , ... ]}
e.g. func(“/home/my/files”) where the directory... (7 Replies)
Hi All,
I hope somebody would be able to help me.
I would need to search a string coming from a file, example file.txt:
dog
cat
goat
horse
fish
For every string, I would need to know if there are any files inside a directory(recursively) that contains the string regardless of case.... (9 Replies)
I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with:
wc -l *|sort
15263 Image.txt
16401 reference.txt
40459 richtexteditor.txt
How can I also print the number of unique lines in each file?
15263 1401 Image.txt
16401... (15 Replies)
Discussion started by: spacegoose
15 Replies
LEARN ABOUT SUNOS
rewinddir
rewinddir(3C) Standard C Library Functions rewinddir(3C)NAME
rewinddir - reset position of directory stream to the beginning of a directory
SYNOPSIS
#include <sys/types.h>
#include <dirent.h>
void rewinddir(DIR *dirp);
DESCRIPTION
The rewinddir() function resets the position of the directory stream to which dirp refers to the beginning of the directory. It also causes
the directory stream to refer to the current state of the corresponding directory, as a call to opendir(3C) would have done. If dirp does
not refer to a directory stream, the effect is undefined.
After a call to the fork(2) function, either the parent or child (but not both) may continue processing the directory stream using read-
dir(3C), rewinddir() or seekdir(3C). If both the parent and child processes use these functions, the result is undefined.
RETURN VALUES
The rewinddir() function does not return a value.
ERRORS
No errors are defined.
USAGE
The rewinddir() function should be used in conjunction with opendir(), readdir(), and closedir(3C) to examine the contents of the direc-
tory. This method is recommended for portability.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |Safe |
+-----------------------------+-----------------------------+
SEE ALSO fork(2), closedir(3C), opendir(3C), readdir(3C), seekdir(3C), attributes(5), standards(5)SunOS 5.10 14 Aug 2002 rewinddir(3C)