2 added 263 characters in body
source | link

Assuming the files are in the current directory, ad that you're using bash:

files=( T*.CDT )
grep 'FCE-Error' "${files[-1]}"

This would grep the most recent .CDT file for the string. You could do the same for the other type of file.

The shell globbing pattern T*.CDT expands to all matching filenames sorted lexicographically, and since you are using sane filenames (with proper timestamps that sorts properly), the last of these will be the latest file.

To mail an alert if the string is found:

files=( T*.CDT )
if grep -q 'FCE-Error' "${files[-1]}"; then
    mail -s 'Alert' someperson@example.com <<END_MESSAGE
We've found "FCE-Error" in ${files[-1]}, do something!
END_MESSAGE
fi

Using some other POSIX shell:

set -- T*.CDT            # set positional parameter to all matching filenames
shift "$(( $# - 1 ))"    # shift off all but the last filename
if grep -q 'FCE-Error' "$@"; then
    mail -s 'Alert' someperson@example.com <<END_MESSAGE
We've found "FCE-Error" in ${files[-1]}, do something!
END_MESSAGE
fi

Assuming the files are in the current directory, ad that you're using bash:

files=( T*.CDT )
grep 'FCE-Error' "${files[-1]}"

This would grep the most recent .CDT file for the string. You could do the same for the other type of file.

The shell globbing pattern T*.CDT expands to all matching filenames sorted lexicographically, and since you are using sane filenames (with proper timestamps that sorts properly), the last of these will be the latest file.

To mail an alert if the string is found:

files=( T*.CDT )
if grep -q 'FCE-Error' "${files[-1]}"; then
    mail -s 'Alert' someperson@example.com <<END_MESSAGE
We've found "FCE-Error" in ${files[-1]}, do something!
END_MESSAGE
fi

Assuming the files are in the current directory, ad that you're using bash:

files=( T*.CDT )
grep 'FCE-Error' "${files[-1]}"

This would grep the most recent .CDT file for the string. You could do the same for the other type of file.

The shell globbing pattern T*.CDT expands to all matching filenames sorted lexicographically, and since you are using sane filenames (with proper timestamps that sorts properly), the last of these will be the latest file.

To mail an alert if the string is found:

files=( T*.CDT )
if grep -q 'FCE-Error' "${files[-1]}"; then
    mail -s 'Alert' someperson@example.com <<END_MESSAGE
We've found "FCE-Error" in ${files[-1]}, do something!
END_MESSAGE
fi

Using some other POSIX shell:

set -- T*.CDT            # set positional parameter to all matching filenames
shift "$(( $# - 1 ))"    # shift off all but the last filename
if grep -q 'FCE-Error' "$@"; then
    mail -s 'Alert' someperson@example.com <<END_MESSAGE
We've found "FCE-Error" in ${files[-1]}, do something!
END_MESSAGE
fi
1
source | link

Assuming the files are in the current directory, ad that you're using bash:

files=( T*.CDT )
grep 'FCE-Error' "${files[-1]}"

This would grep the most recent .CDT file for the string. You could do the same for the other type of file.

The shell globbing pattern T*.CDT expands to all matching filenames sorted lexicographically, and since you are using sane filenames (with proper timestamps that sorts properly), the last of these will be the latest file.

To mail an alert if the string is found:

files=( T*.CDT )
if grep -q 'FCE-Error' "${files[-1]}"; then
    mail -s 'Alert' someperson@example.com <<END_MESSAGE
We've found "FCE-Error" in ${files[-1]}, do something!
END_MESSAGE
fi