Hello friends,
There is one requirment where I need to login into database environment and pull all schema names into a text file ...
as of now below are the schemas available...
$> describe keyspaces;
system_schema system_auth system abc system_distributed system_traces
Now from unix script I need to fetch all these names into a file for further processing, so i wrote command like
## List All Keyspaces
cqlsh myhostname -e "DESC KEYSPACES" | awk '{print $1 "\n" $2 "\n" $3 "\n"}'| grep -v "^$" | sort > Keyspace_name_schema.cql
But I am getting only below values as output.
system
system_auth
system_schema
the below are omitted
abc system_distributed system_traces
However, same script working fine on different environment(exactly configure like this environment) ..its driving me crazy...
Can anyone suggest..
RudiC
2
Try
awk '{for (i=1; i<=NF; i++) if ($i ~ /system/) print $i}'
.
EDIT: The struck through if
was because I misread your spec to only contain system related tables...
1 Like
Hi thanks for reply,
But now its omitting analytic only below are captured
system
system_auth
system_distributed
system_schema
system_traces
any other suggesstion
------ Post updated at 05:41 AM ------
sorry, didnt see your update in post..
awk '{for (i=1; i<=NF; i++) if ($i ~ /system/) print $i}'
now this work fine thank you so much
------ Post updated at 05:42 AM ------
thank yoyu
did not notice your update in post
awk '{for (i=1; i<=NF; i++) print $i}'
this is working super..thanks a lot
echo '
system_schema system_auth system abc system_distributed system_traces' | tr ' ' '\n' | sed '/^$/d'
RudiC
5
If you're using sed
anyhow, why not eliminate tr
?
echo '
system_schema system_auth system abc system_distributed system_traces' | sed '/^$/d; s/ */\n/g'