“Bash leia várias linhas do usuário” Respostas de código

Bash leia várias linhas do usuário

# Basic syntax:
read -d "~" -p $'Enter your text (type \"~~\" when done):\n' YOUR_TEXT
# Where:
#	- -d tells read to continue reading until the specified delimiter is read.
#		Here I use ~ as the delimiter
#	- -p indicates what to prompt when the script asks for input. I include a
#		message to indicate what to type to stop reading. (I say ~~ because in
#		my shell, I always seem to have to press it twice to stop reading)
#	- YOUR_TEXT is the bash variable that will get the input text 
Charles-Alexandre Roy

Leia a entrada de várias linhas em Bash

user@host:~$ read -d '' x <<EOF
> mic
> check
> one
> two
> EOF
Gifted Gorilla

Leia a entrada de várias linhas em Bash

$ myVar=$(</dev/stdin)
hello
this is test
$ echo $myVar
hello this is test
$ echo "$myVar"
hello
this is test
Gifted Gorilla

Respostas semelhantes a “Bash leia várias linhas do usuário”

Perguntas semelhantes a “Bash leia várias linhas do usuário”

Mais respostas relacionadas para “Bash leia várias linhas do usuário” em Shell/Bash

Procure respostas de código populares por idioma

Procurar outros idiomas de código