0

deppfx@localhost:/tmp$ echo ${$(hostname): -3}

-bash: ${$(hostname): -3}: bad substitution

I am looking for the output as ost.

Related: https://stackoverflow.com/a/19858692/598175

Community
  • 1
  • 1
deppfx
  • 701
  • 1
  • 10
  • 24

2 Answers2

2

It should be ${variable: -3}. Don't try to substitute command.

Srini V
  • 11,045
  • 14
  • 66
  • 89
Mahesh Kharvi
  • 389
  • 2
  • 6
1

The substitution works in variables, not in commands.

echo $(myVar=$(hostname);echo ${myVar: -3})
blashser
  • 921
  • 6
  • 13