Grepping the
output of ls? Please, just say no.
If a simple find command won't do, I'd run the filenames in a loop and use the shell's built-in testing ability.
Code:
for file in *.csv; do
[[ ! $file =~ $UDATE ]] && rm "$file"
done
If you want to make it more robust, you should load the list of filenames into an array first, and work on that. Avoid storing lists of things inside single scalar variables.
I'm not too familiar with
ksh, but it should have built-in features for converting variable values to upper or lower case. A quick test in
ksh shows that bash's
${var^^} pattern doesn't work, but setting "
typeset -u var" first does, at least, which means there's likely some way to echo it at will as well.
Code:
$ typeset -u var=foo
$ echo "$var"
FOO
Also,
$(..) is highly recommended over `..`.
Finally, environment variables are generally all upper-case. So while not absolutely necessary, it's good practice to keep your own user variables in lower-case or mixed-case, to help differentiate them.