I have an array c_arr containing table columns with table aliases. But there are some elements in the array which are actually not columns and so they don't have the format alias.column_name.
I need to remove those elements which do not contain a .. How can I do that?
The array is created using below statement:
c_arr=($echo $(grep -io "\b$alias.\w[a-zA-Z_0-9]*" $output_file))
There is another problem with the above line. Even though I am searching for $alias. (having a dot after the alias), the array c_arr is getting other values too which do not contain a dot.
Sample values of the array are as follows:
cab.SYSTEM_NAME
cab.row_id
cab.name
cabxa
cabxa
cab.x_sys_name
cab.status_Cd
cab.LAST_UPD
UPDATE:
Now, the question at hand is how to remove the elements in the array c_arr which does not contain the character . if at all the array is having dot and non-dot elements. Contents of c_arr is as below:
cab.SYSTEM_NAME
cab.row_id
cab.name
cabxa
cabxa
cab.x_sys_name
cab.status_Cd
cab.LAST_UPD
The output desired is :
cab.SYSTEM_NAME
cab.row_id
cab.name
cab.x_sys_name
cab.status_Cd
cab.LAST_UPD
.matches any single character. To search for a literal.you need to escape by preceding with a backslash:\b$alias\.\w[a-zA-Z_0-9]*. Also,\wis equivalent to[a-zA-Z_0-9]mapfile -t c_arr <(grep ...)and usedeclare -p c_arrto view the contents.$echois that an variable you have set?