Variables not working

Hello,
I have a (basic I guess) problem with bash scripting.
In the command line, this piece of code returns nothing (a blank line), and if I'm not worng it should return 3.

set VAR = "3"
echo $VAR

if I do this (also in command line), a zero is returned:

set VAR = 3
printf "%d" "$VAR"

I also tried this code, with the same result, nothing is shown

#!/bin/bash
clear
 
set PID = 3;
echo $PID;

I hope someone can help me, this is cracking my nut.
Thankx in advanced.

set PID = 3

is not Bash syntax. It's CSH syntax:

$ csh
% set PID = 3
% echo $PID
3
PID=3

is Bash syntax.

You can use:

set PID=3

but it's not necessary to use set.

I also tryied that: VAR = "3"; echo $VAR

with this result: bash: VAR: command not found

thankx eitherway

There should be no spaces either side of =.

1 Like

that was it.

thank you very much for your help