Skip to content
Snippets Groups Projects
Commit 98a07d4b authored by Gael  MILLOT's avatar Gael MILLOT
Browse files

v1.3.0 release

parent 6db973d6
No related branches found
Tags v1.3.0
No related merge requests found
...@@ -56,6 +56,11 @@ Check for updated versions (more recent release tags) at https://gitlab.pasteur. ...@@ -56,6 +56,11 @@ Check for updated versions (more recent release tags) at https://gitlab.pasteur.
#### WHAT'S NEW IN #### WHAT'S NEW IN
## v1.3.0
test_column_nb_perline_in_file_fun with better writting
## v1.2.0 ## v1.2.0
output file name error in test_column_nb_perline_in_file_fun fixed output file name error in test_column_nb_perline_in_file_fun fixed
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
################################################################ ################################################################
## ## ## ##
## LITTLE BASH FUNCTIONS v1.2.0 ## ## LITTLE BASH FUNCTIONS v1.3.0 ##
## ## ## ##
## Gael A. Millot ## ## Gael A. Millot ##
## ## ## ##
...@@ -309,14 +309,14 @@ function test_column_nb_perline_in_file_fun () { ...@@ -309,14 +309,14 @@ function test_column_nb_perline_in_file_fun () {
((OPTIND--)) # or ((OPTIND-1)) ? ((OPTIND--)) # or ((OPTIND-1)) ?
fi fi
} }
local OPTIND OPTION i o d l INPUT_FUN OUTPUT_FUN OUTPUT_WOPATTERN_FUN CHARACTER_FUN local OPTIND OPTION i o d l INPUT_FUN OUTPUT_ERROR_FUN OUTPUT_WO_ERROR_FUN CHARACTER_FUN
while getopts ":i:o:c:d:" OPTION ; do while getopts ":i:o:c:d:" OPTION ; do
# add : after the option name to specify that something is required (-h has nothing required after) # add : after the option name to specify that something is required (-h has nothing required after)
# the first : before h is to induce getopts switching to "silent error reporting mode" (disable annoying messages). # the first : before h is to induce getopts switching to "silent error reporting mode" (disable annoying messages).
case $OPTION in case $OPTION in
i) verif $OPTARG ; INPUT_FUN=$OPTARG ;; i) verif $OPTARG ; INPUT_FUN=$OPTARG ;;
o) verif $OPTARG ; OUTPUT_FUN=$OPTARG ;; o) verif $OPTARG ; OUTPUT_ERROR_FUN=$OPTARG ;;
c) verif $OPTARG ; OUTPUT_WOPATTERN_FUN=$OPTARG ;; c) verif $OPTARG ; OUTPUT_WO_ERROR_FUN=$OPTARG ;;
d) verif $OPTARG ; CHARACTER_FUN=$OPTARG ;; d) verif $OPTARG ; CHARACTER_FUN=$OPTARG ;;
\?) echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### INVALID OPTION\n" ; return 1 ;; \?) echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### INVALID OPTION\n" ; return 1 ;;
:) echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### OPTION -${OPTARG} REQUIRES AN ARGUMENT\n" ; return 1 ;; :) echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### OPTION -${OPTARG} REQUIRES AN ARGUMENT\n" ; return 1 ;;
...@@ -331,18 +331,18 @@ function test_column_nb_perline_in_file_fun () { ...@@ -331,18 +331,18 @@ function test_column_nb_perline_in_file_fun () {
echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### ${INPUT_FUN} FILE NOT PRESENT IN `dirname $INPUT_FUN`\n" echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### ${INPUT_FUN} FILE NOT PRESENT IN `dirname $INPUT_FUN`\n"
return 1 return 1
fi fi
if [[ -z $OUTPUT_FUN ]]; then if [[ -z $OUTPUT_ERROR_FUN ]]; then
local OUTPUT_FUN=${INPUT_FUN}_error_line local OUTPUT_ERROR_FUN=${INPUT_FUN}_error_line
fi fi
if [[ -f $OUTPUT_FUN ]]; then if [[ -f $OUTPUT_ERROR_FUN ]]; then
echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### ${OUTPUT_FUN} FILE ALREADY EXISTS\n" echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### ${OUTPUT_ERROR_FUN} FILE ALREADY EXISTS\n"
return 1 return 1
fi fi
if [[ -z $OUTPUT_WOPATTERN_FUN ]]; then if [[ -z $OUTPUT_WO_ERROR_FUN ]]; then
local OUTPUT_WOPATTERN_FUN=${INPUT_FUN}_wo_error_line local OUTPUT_WO_ERROR_FUN=${INPUT_FUN}_wo_error_line
fi fi
if [[ -f $OUTPUT_WOPATTERN_FUN ]]; then if [[ -f $OUTPUT_WO_ERROR_FUN ]]; then
echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### ${OUTPUT_WOPATTERN_FUN} FILE ALREADY EXISTS\n" echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### ${OUTPUT_WO_ERROR_FUN} FILE ALREADY EXISTS\n"
return 1 return 1
fi fi
if [[ -z $CHARACTER_FUN ]]; then if [[ -z $CHARACTER_FUN ]]; then
...@@ -364,29 +364,29 @@ function test_column_nb_perline_in_file_fun () { ...@@ -364,29 +364,29 @@ function test_column_nb_perline_in_file_fun () {
echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### THE FIRST LINE OF $INPUT_FUN IS EMPTY: USE file_pattern_detection_fun TO REMOVE EMPTY LINES\n" echo -e "\n### test_column_nb_perline_in_file_fun ERROR ### THE FIRST LINE OF $INPUT_FUN IS EMPTY: USE file_pattern_detection_fun TO REMOVE EMPTY LINES\n"
return 2 return 2
fi fi
awk -F "$CHARACTER_FUN" -v var1=$NB_COL_FIRSTLINE 'NF!=var1{print NR, $0}' $INPUT_FUN > ${OUTPUT_FUN} # recover the error lines awk -F "$CHARACTER_FUN" -v var1=$NB_COL_FIRSTLINE 'NF!=var1{print NR, $0}' $INPUT_FUN > ${OUTPUT_ERROR_FUN} # recover the error lines
awk -F "$CHARACTER_FUN" -v var1=$NB_COL_FIRSTLINE 'NF==var1{print $0}' $INPUT_FUN > $OUTPUT_WOPATTERN_FUN awk -F "$CHARACTER_FUN" -v var1=$NB_COL_FIRSTLINE 'NF==var1{print $0}' $INPUT_FUN > $OUTPUT_WO_ERROR_FUN
# rm $INPUT_FUN # rm $INPUT_FUN
local NB_ERROR_LINES=$(wc -l < "${OUTPUT_FUN}") # number of error lines local NB_ERROR_LINES=$(wc -l < "${OUTPUT_ERROR_FUN}") # number of error lines
if [[ $NB_ERROR_LINES == 0 ]] ; then if [[ $NB_ERROR_LINES == 0 ]] ; then
echo -e "\ntest_column_nb_perline_in_file_fun MESSAGE: NO DIFFERENT COLUMN NUMBER FOUND IN LINES OF ${INPUT_FUN} HAVING $NB_COL_FIRSTLINE COLUMNS IN THE FIRST LINE\n" echo -e "\ntest_column_nb_perline_in_file_fun MESSAGE: NO DIFFERENT COLUMN NUMBER FOUND IN LINES OF ${INPUT_FUN} HAVING $NB_COL_FIRSTLINE COLUMNS IN THE FIRST LINE\n"
rm ${OUTPUT_FUN} rm ${OUTPUT_ERROR_FUN}
rm ${OUTPUT_WOPATTERN_FUN} rm ${OUTPUT_WO_ERROR_FUN}
return 0 return 0
elif [[ $NB_ERROR_LINES == $(( ${TOTAL_NB_LINES} - 1 )) ]]; then elif [[ $NB_ERROR_LINES == $(( ${TOTAL_NB_LINES} - 1 )) ]]; then
echo -e "\ntest_column_nb_perline_in_file_fun MESSAGE: ONLY THE FIRST LINE HAS A DIFFERENT COLUMN NUMBER FROM THE REST OF THE ${INPUT_FUN} FILE\nTHE FIRST LINE IS:\n$(head -n 1 $INPUT_FUN)" echo -e "\ntest_column_nb_perline_in_file_fun MESSAGE: ONLY THE FIRST LINE HAS A DIFFERENT COLUMN NUMBER FROM THE REST OF THE ${INPUT_FUN} FILE\nTHE FIRST LINE IS:\n$(head -n 1 $INPUT_FUN)"
rm ${OUTPUT_FUN} rm ${OUTPUT_ERROR_FUN}
rm ${OUTPUT_WOPATTERN_FUN} rm ${OUTPUT_WO_ERROR_FUN}
return 3 return 3
else else
echo -e "test_column_nb_perline_in_file_fun MESSAGE: ${NB_ERROR_LINES} LINES FOUND IN ${INPUT_FUN} SHOWING A NUMBER OF COLUMN DIFFERENT FROM $NB_COL_FIRSTLINE COLUMNS AS FOUND IN THE FIRST LINE\n" # | tee -a $OUTPUT_FUN echo -e "test_column_nb_perline_in_file_fun MESSAGE: ${NB_ERROR_LINES} LINES FOUND IN ${INPUT_FUN} SHOWING A NUMBER OF COLUMN DIFFERENT FROM $NB_COL_FIRSTLINE COLUMNS AS FOUND IN THE FIRST LINE\n" # | tee -a $OUTPUT_ERROR_FUN
# echo -e "THE PROBLEMATIC LINES ARE:\n" >> $OUTPUT_FUN # echo -e "THE PROBLEMATIC LINES ARE:\n" >> $OUTPUT_ERROR_FUN
if(( ${NB_ERROR_LINES} <= 200 )) ; then # display if less than 200 if(( ${NB_ERROR_LINES} <= 200 )) ; then # display if less than 200
echo -e "\ntest_column_nb_perline_in_file_fun MESSAGE: THE PROBLEMATIC LINES ARE:\n" echo -e "\ntest_column_nb_perline_in_file_fun MESSAGE: THE PROBLEMATIC LINES ARE:\n"
cat ${OUTPUT_FUN} cat ${OUTPUT_ERROR_FUN}
echo -e "\n\n" echo -e "\n\n"
else else
echo -e "\ntest_column_nb_perline_in_file_fun MESSAGE: THE PROBLEMATIC LINES ARE MORE THAN 200 -> ONLY PRINTED IN THE $OUTPUT_FUN FILE:\n" echo -e "\ntest_column_nb_perline_in_file_fun MESSAGE: THE PROBLEMATIC LINES ARE MORE THAN 200 -> ONLY PRINTED IN THE $OUTPUT_ERROR_FUN FILE:\n"
fi fi
return 4 return 4
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment