bigjim
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by bigjim
-
-
I am a student in a Linux class. I need to be able to search for lines within a file for certain text. The script I have written runs but delivers an empty array. I know the /etc/crontab file has the word "test" but I can't seem to get this to work properly. This is not my finished work, I just need to get the preg_grep function working before I can go any further.SCRIPT#! /usr/bin/php<?php fwrite(STDOUT, "Enter the name of the file you wish to open \n");$file = array(trim(fgets(STDIN)));$grepfile = preg_grep ( "/test/" , $file );print_r($grepfile);?>OUTPUTbigjim3@bigjim3-desktop:~$ ./assign4.phpEnter the name of the file you wish to open /etc/crontabArray()bigjim3@bigjim3-desktop:~$ Thoughts, Suggestions, Hints?TIA
preg_grep
in PHP
Posted