echo "
SET SERVEROUT ON SIZE 100000
SET FEED OFF
DECLARE
var_px_cat number:=0;
BEGIN
DBMS_OUTPUT.enable(1000000);
SELECT COUNT(*) INTO var_px_cat
FROM A
WHERE B = '$CATEGORIE_ID';
DBMS_OUTPUT.PUT(var_px_cnr);
DBMS_OUTPUT.NEW_LINE;
END;
/
" | sqlplus user/pswd@someplace | read myvar
echo "myvar is now $myvar"
There are other ways - write to a file with UTL_FILE then read the file contents
If the declaration of the PL/SQL variable was solely for passing its value to the Unix shell, then you don't really need it.
...
count=`sqlplus -s username/password@sid <<EOF
set pages 0 feed off
SELECT COUNT(*)||''
FROM A
WHERE B = '$CATEGORIE_ID';
exit
EOF`
echo "Count = $count"
...