Hi I am new to shell script. I have a command like this.
awk 'BEGIN{ print "Query" }
/Executing command\(queryId/{ sub(/.*queryId=[^[:space:]]+: /,""); q=$0 }
/s3:\/\//{ print q }' OFS=',' hive-server2.log
It prints the output perfectly like this.
select * from claimpfphdr limit 5
select * from claimpfphdr limit 5
select * from claimpfphdr limit 5
But When I use the same command to add the result in variable, Like this.
a=$(awk 'BEGIN{ print "Query" }
/Executing command\(queryId/{ sub(/.*queryId=[^[:space:]]+: /,""); q=$0 }
/s3:\/\//{ print q }' OFS=',' hive-server2.log)
It adds unwanted values.This is the output of the above shell variable.
echo $a
Query select License.txt LogMX-64.exe LogMX.app LogMX.bat LogMX.exe Log_Copyier.sh Readme.txt config help hive-server2.log jar lib logmx.command logmx.sht1.sh test.txt test_result.txt from pfeevent limit
Any help will be appreciated.