grep readdir


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting grep readdir
# 1  
Old 05-14-2009
grep readdir

Quick question.

I can not get the context corrert on this code.

PHP Code:
opendir(DIR".");
@
fileldiv grep(/l*/,readdir(DIR));
closedir(DIR); 
I am trying to search all html files within a dir that start with l.

Thanks for your help.
# 2  
Old 05-14-2009
I figured it out.

#!/usr/bin/perl

use strict;
use warnings;

my @files = glob("l*.*");

foreach my $file (@files) {

print "$file\n";

}

exit
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

2. UNIX for Dummies Questions & Answers

Bash - CLI - grep - Passing result to grep through pipe

Hello. I want to get all modules which are loaded and which name are exactly 2 characters long and not more than 2 characters and begin with "nv" lsmod | (e)grep '^nv???????????? I want to get all modules which are loaded and which name begin with "nv" and are 2 to 7 characters long ... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Programming

readdir and dynamic array memory corruption

Hi everyone I am developing an utility. At some part of it I read directory entries to a dynamic array: struct list It stores pointers to items: list.entries, which are structures: struct entry If a number of files in a directory is greater then number of elements an array was initially... (11 Replies)
Discussion started by: torbium
11 Replies

4. UNIX for Dummies Questions & Answers

| help | unix | grep (GNU grep) 2.5.1 | advanced regex syntax

Hello, I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide. ls -aLl /bin | grep "\(x\)" Which works, just highlights 'x' where ever, when ever. I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies

5. SuSE

problem of readdir on IA64 suse

Dear Experts, i am trying to find whether the given name is file or a directory dirp = opendir(dirname); direntp = readdir(dirp); if(direntp->d_type & DT_DIR) { printf("\n is a dirctory"); } else { //dir_or_file = Mtrue; printf("\n not a directory"); } it always... (9 Replies)
Discussion started by: vin_pll
9 Replies

6. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

7. Programming

Finding wildcards in readdir

I am having a hard time doing this and can't seem to find an example to help me. This is my code: DIR *dirp=opendir(pathname); struct stat filebuf; struct dirent entry; struct dirent *dp=&entry; RWCString pattern; for (int i = 0; i < request_->getNumStreams(); i++) { ... (2 Replies)
Discussion started by: ajgwin
2 Replies

8. Programming

diren.h : readdir( ) - sorting requirement

hi all, im using dirent.h headers readdir() function to traverse down a directory ( after openning it with opendir() ), and im printing the dir->d_name in a program. while(( dir = readdir( d ) ) != NULL ){ if (stat(, &info) != 0){ fprintf(stderr, "stat() error on %s: %s\n",... (2 Replies)
Discussion started by: wolwy_pete
2 Replies

9. UNIX for Dummies Questions & Answers

how to man readdir(3)

I read the description of the command readdir by using 'man readdir'. However, in the description i was suggesed to refer to readdir(3). I wonder how to see the manual of readdir(3) Thanks (1 Reply)
Discussion started by: cy163
1 Replies

10. Filesystems, Disks and Memory

Preblem with readdir system call

I am trying to read the directory contents throgh the readdir system call. After getting the directory entry I am testing the type of it by using the folllowing macros S_ISDIR() S_ISREG() etc. But in some systems every file in the directory is displaying like a sub directory. and in some systems... (2 Replies)
Discussion started by: gandhevinod
2 Replies
Login or Register to Ask a Question