1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Parsing a log file and storing it in database however the database remains empty on querying

Discussion in 'Shell Script' started by Tej, May 22, 2019.

  1. Tej

    Tej New Member

    Joined:
    May 21, 2019
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    Hello All,
    I was parsing a log file and storing the values in thetable,I dont know how to handle the variables so that value gets stored in the databasetable:

    #!bin/bash
    file="/home/tej/filechanges"
    cat $file |while read line
    do
    operation= echo $line|cut -f1 -d" "
    changes= echo $line|cut -f2 -d" "
    mysql -u username -ppassword -e "use dockerlogs;INSERT INTO logs(operation,file) VALUES (/"$operation/",/"$changes/")"
    done

    but the database comes empty,instead of /$operation and $changes I store it as ('1','1'); the values do get stored,how to handle the variables?

    Thanks and Regards
    Tej Gandhi
     
    Last edited: May 22, 2019

Share This Page