ckwan
1
Hi All,
Would like to ask on how to refrain the message file not exists from display out.
if [ `ls ${src}_*/*.CTL |awk '{print $1}'|wc -l ` -gt 0 ]; then
When it execute, the OS will throw the error file does not exists
ls: 0653-341 The file COL_*/*.CTL does not exist.
Thanks.
The file you are trying to list does not exist
if ls ${src}_*/*.CTL &> /dev/null; then
echo "yes files are there"
else
echo "No files"
fi
1 Like
Try:
if [ $(ls ${src}_*/*.CTL 2>/dev/null|wc -l) -gt 0 ]; then
or:
if ls ${src}_*/*.CTL >/dev/null 2>&1; then
1 Like
ckwan
4
Thanks All, Yes you right
2>/dev/null
will not show the error out. Great for sharing.