1 of 2

How to execute the following commands at once in ubuntu using postgresql?

echo "Go1 Assigned Strength">>result.csv && echo

$''>>result.csv && psql abc -c "Select

empl.emp_status,count(empl.id) from hr_employee as empl

inner join unit_identification_code as uic on empl.unit_identificatin_code_id=uic.id inner join

ana_rank as rank on rank.id=empl.rank_id where rank.name not in

('C1','C2','C3','C4','C5','C6','C7','C8','Civ1','Civ10','Civ

11','Civ12','Civ13','Civ14', 'Civ15','Civ16','Civ2','Civ3','Civ4','Civ5','Civ6','Civ7','C

iv8','Civ9','G1','G2', 'G3','G4','G5','G6','OOR','OR','R1','R10','R2','R3','R4','R5

','R6','R7','R8','R9') and uic.code in ('Z00100', 'Z00200', 'Z00300', 'Z00400',

'Z00450', 'Z00500', 'Z00698', 'Z00600', 'Z00680', 'Z00697',

'Z00699', 'Z00700', 'Z00800', 'Z00900', 'Z01000', 'Z01100',

'Z01200', 'Z01300', 'Z39000', 'Z39010', 'Z39012','Z10000',

'Z10009', 'Z10100', 'Z10200', 'Z10300', 'Z10400', 'Z10450',

'Z10005', 'Z10500', 'Z10007', 'Z10600', 'Z10700', 'Z10800',

'Z10900', 'Z20000', 'Z11000', 'Z13000', 'Z10101', 'ZNTIC1',

'Z36000', 'Z37000', 'Z10301', 'ZACA97') group by

empl.emp_status">result.csv && echo $''>>result.csv && echo "Go1 Assigned Strength

Civi">>result.csv && psql abc -c "Select empl.emp_status,count(empl.id) from

hr_employee as empl inner join unit_identification_code as

uic on empl.unit_identificatin_code_id=uic.id inner join

ana_rank as rank on rank.id=empl.rank_id where rank.name in

('C1', 'C2','C3','C4','C5','C6','C7','C8','Civ1','Civ10','Civ11','C

iv12','Civ13','Civ14', 'Civ15','Civ16','Civ2','Civ3','Civ4','Civ5','Civ6','Civ7','C

iv8','Civ9','G1','G2', 'G3','G4','G5','G6','OOR','OR','R1','R10','R2','R3','R4','R5

','R6','R7','R8','R9') and uic.code in ('Z00100', 'Z00200', 'Z00300', 'Z00400',

'Z00450', 'Z00500', 'Z00698', 'Z00600', 'Z00680', 'Z00697',

'Z00699', 'Z00700', 'Z00800', 'Z00900', 'Z01000', 'Z01100',

'Z01200', 'Z01300', 'Z39000', 'Z39010', 'Z39012','Z10000',

'Z10009', 'Z10100', 'Z10200', 'Z10300', 'Z10400', 'Z10450',

'Z10005', 'Z10500', 'Z10007', 'Z10600', 'Z10700', 'Z10800',

'Z10900', 'Z20000', 'Z11000', 'Z13000', 'Z10101', 'ZNTIC1',

'Z36000', 'Z37000', 'Z10301', 'ZACA97') group by

empl.emp_status">>result.csv