'How to combine multiple commands output in the one varialble in shell script?
I'm using the following script to get the data of one of the variables from the database file
#!/bin/bash
sqlite3 pdu.db <<'END_SQL'
.timeout 2000
SELECT Variable_Value FROM Data Where Sr_No'7';
END_SQL
Now I wanted to store the output of the above commands in one variable. How we can store multiple commands output in one variable in the shell script?
Solution 1:[1]
There's no restriction against putting a multiline command inside a command substitution.
variable=$(sqlite3 /var/www/dbs/ha.db <<'END_SQL'
.timeout 2000
INSERT INTO table1 SELECT * FROM table2;
DELETE FROM table2;
END_SQL
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Barmar |