Skip to content
Advertisement

Tag: bash

Linux – Store a sql select value in a variable bash

I want to store the value of the sqlite statement in a variable backup=$(sqlite3 “/home/miguel/Desktop/SO/ProjetoFinal/Backup_Principal.db” “SELECT periocidade_backup FROM STORAGE WHERE path’$path’;”) But when i echo $backup it returns the following: sqlite3 “/home/miguel/Desktop/SO/ProjetoFinal/Backup_Principal.db” “SELECT periocidade_backup FROM STORAGE WHERE path=’$path’;” What am I doing wrong? Answer the part of your code ‘$path’ is using a single quote which is literal and show

Add more new lines to end of line in stdout

I want to be able to print out my logs with extra new lines. This is what the logs look like They look much cluttered in the terminal and although there is a newline, I want to add 1 more newline to make it more readable. I tried using and to no avail. Answer Not entirely certain about portability, but

Is there any way to auto-send a “no” response to a script?

For example, I have this script: I can run yes | bash script and the script will automatically output “yes” I want to know if I can send a negative response to it and automatically output “no”. Sorry if this has been asked before but I can’t find anything related. Answer yes repeatedly outputs a string that you give it

read the first line of a text file with JQ

Trying to see how I can read the first line of a text file using jq I have a text file with a bunch of ids (newfile.txt ) id like to be able to just read the first line with jq. I tried doing this But getting an error of I’d like to be able to read line by line

run multiple commands in docker after container start

how can I run /bin/run1.sh and /bin/run2.sh after the container startup! also, if you can tell me how can I send the logs of /bin/run1.sh and /bin/run2.sh to container logs!! Docker file entrypoint.sh run1.sh run2.sh Answer You can change ENTRYPOINT [“entrypoint.sh”] to ENTRYPOINT [“entrypoint.sh”, “run1.sh”, “run2.sh”] which will run your custom bash scripts you also need to create the log.txt

Nested bash loop runs but logic is not correct

I have this nested bash for loop where the first loop represents the range of servers, and the second loop reads each lines of the .txt file. Then will do a zgrep -i and find for a string on the matching line. keys.txt is as follow: Bash Loops: This runs but its logging every instance where ‘InitialRequest’ is defined. What

Advertisement