Is there any shell script that we can use to check the file extension, format or even the readability? The answer is yes and we recommend you plug in these code into program before processing any files.
Why check the file extension, format and the readability important in your shell script program?
It’s vital to confirm that the filename your system receive for processing is in .txt or .dat as agreed with other source system.
The second thing you want to make sure is the file format in ascii instead of binary before loading. In the end, confirm the readability of the flat file using the -r feature in shell command.
Refer the shell script as below to check the flat file extension, format and the readability.
v_ext=`echo $v_file_name | cut -f2 -d '.'`
if [ "$v_ext" != "txt" ]
echo "File is not .txt extension"
echo "File is with .txt extension"
v_read=`file $v_file_name | cut -f2`
if [ "$v_read" != "ascii text" ]
echo "File is not in ascii text format"
echo "File is in ascii text format"
if [ ! -r $v_file_name ]
echo "File is not readable"
echo "File is readable"
Next» Oracle Session Longops - Long Running SQL