in reply to Unix shell ls vs readdir
my @lines = grep {/->\s+tomcat\s+/} qx{ls -l /etc/rc.d/init.d}; my @inits = map {(split)[-3]} @lines;
If /etc/rc.d/init.d contains any subdirectories then ls will also display the files from them. Is that what you want?
If any of the file names contains spaces or tabs or newlines (or other whitespace characters) then (split)[-3] will not return the correct file name.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unix shell ls vs readdir
by jffry (Hermit) on May 11, 2010 at 03:36 UTC |