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.In reply to Re: Unix shell ls vs readdir
by jwkrahn
in thread Unix shell ls vs readdir
by jffry
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |