Questions tagged [parameter-expansion]

Parameter expansion replaces variables with their values as an evaluation phase of a command in most Bourne-derived shells.

Parameter expansion is one of the series of transformations that commands go through when evaluated in a shell.

Its main function is to interpolate parameters, a.k.a. shell variables, but it also allows for some manipulation. For example, in bash, assuming variable var contains the string 1234abcd:

  • $var expands to 1234abcd
  • ${#var} expands to the parameter's length, 8
  • ${var%cd} expands to the parameter tail-trimmed of cd: 1234ab

Section parameter expansion from bash's Reference Manual

167 questions
-2
votes
3 answers

parameter expansion default ":=" vs "=" vs ":-" vs "-"

I've seen several different methods of using default values in parameter expansions in Bourne-derived shells: :=, =, :- and -. I'm wondering how they differ. The manual says that - and = handle null values differently from :- and :=. But as far as I…
Jacob Stern
  • 3,758
  • 3
  • 32
  • 54
-2
votes
2 answers

Some Output Lost in Command Passed to SSH

I'm trying to use an ssh command to ssh to a server and run theuseradd command I passed to it. It seems like its running ok for the most part (no errors produced) but the hashed password in the /etc/shadow file is missing the salt (I believe that's…
Matt
  • 413
  • 1
  • 10
  • 16
1 2 3
11
12