Skip to main content
Formatting
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

#II have this command that I've created and would like to place it in a variable.

sort -k 1,1 | tr " " "\n" | users | wc -l

sort -k 1,1 | tr " " "\n" | users | wc -l

#SuchSuch as the one bellowbelow, however, as of now the output produces an error and does not work correctly

us_num=$(users | tr " " "\n" | sort -k 1,1 | wc -l)

echo "Currently there is $(us_num) number of users on the server."

us_num=$(users | tr " " "\n" | sort -k 1,1 | wc -l)
echo "Currently there is $(us_num) number of users on the server."

#AnyAny ideas?

#I have this command that I've created and would like to place it in a variable.

sort -k 1,1 | tr " " "\n" | users | wc -l

#Such as the one bellow, however, as of now the output produces an error and does not work correctly

us_num=$(users | tr " " "\n" | sort -k 1,1 | wc -l)

echo "Currently there is $(us_num) number of users on the server."

#Any ideas?

I have this command that I've created and would like to place it in a variable.

sort -k 1,1 | tr " " "\n" | users | wc -l

Such as the one below, however, as of now the output produces an error and does not work correctly

us_num=$(users | tr " " "\n" | sort -k 1,1 | wc -l)
echo "Currently there is $(us_num) number of users on the server."

Any ideas?

added 35 characters in body
Source Link
Tony
  • 1
  • 1

#I have this command that I've created and would like to place it in a variable.

variable.

sort -k 1,1 | tr " " "\n" | users | wc -l

#such#Such as the one bellow but, however, as of now the output produces an error and does not work correctly in the string

echo "Currently there is $(us_num) number of users on the server."

us_num=$(users | tr " " "\n" | sort -k 1,1 | wc -l)

echo "Currently there is $(us_num) number of users on the server."

#Any ideas?

#I have this command that I've created and would like to place it in a

variable.

sort -k 1,1 | tr " " "\n" | users | wc -l

#such as the one bellow but does not work correctly in the string

echo "Currently there is $(us_num) number of users on the server."

us_num=$(users | tr " " "\n" | sort -k 1,1 | wc -l)

#Any ideas?

#I have this command that I've created and would like to place it in a variable.

sort -k 1,1 | tr " " "\n" | users | wc -l

#Such as the one bellow, however, as of now the output produces an error and does not work correctly

us_num=$(users | tr " " "\n" | sort -k 1,1 | wc -l)

echo "Currently there is $(us_num) number of users on the server."

#Any ideas?

Source Link
Tony
  • 1
  • 1

bash command variable creation

#I have this command that I've created and would like to place it in a

variable.

sort -k 1,1 | tr " " "\n" | users | wc -l

#such as the one bellow but does not work correctly in the string

echo "Currently there is $(us_num) number of users on the server."

us_num=$(users | tr " " "\n" | sort -k 1,1 | wc -l)

#Any ideas?