aero
aero

Reputation: 69

bash script runs but does not display values

my script runs without any errors but does not display the variable values. The output of the screen is two spaced blank lines.

#! /bin/bash

set v1=25
set v2 [format "%c" $v1]

echo "$v1"
echo "$v2"

Upvotes: 0

Views: 36

Answers (1)

chepner
chepner

Reputation: 530940

set isn't used to set the value of a regular variable; it is used to set the positional parameters.

$ set v1=25
$ echo "$1"
v1=25
$ v1=25
$ echo "$v1"
25

Based on [format "%c" $v1], you appear to be writing a hybrid of Tcl and shell.Abash` equivalent would be

v2=$(printf "\x$(printf '%x' "$v1"))

Upvotes: 2

Related Questions