Posted by Christian Ashby on April 28, 2010
If you are writing a BASH script which searches for a file pattern in a folder using this syntax:
[-f {pattern}]
Instead, use the following syntax:
files=$(ls {pattern} 2> /dev/null | wc -l)
if [ "$files" != "0" ]
This can be replaced with a similar command using find if required.
Tags: bash, debian, linux, ubuntu
This entry was posted
on Wednesday, April 28th, 2010 at 10:14 am and is filed under Linux.
You can follow any responses to this entry through the RSS feed.
You can leave a response, or trackback from your own site.