Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash read multiple lines from user

# Basic syntax:
read -d "~" -p $'Enter your text (type "~~" when done):
' 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 
Comment

read input from multiple lines in BASH

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

read input from multiple lines in BASH

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

PREVIOUS NEXT
Code Example
Shell :: yii3 install 
Shell :: venv git 
Shell :: how to install simple screen recorder in fedora 
Shell :: snap powershell 
Shell :: where is upower linux 
Shell :: ubuntu install influx 
Shell :: git request-pull 
Shell :: linux set partition label 
Shell :: mongodb install windows 
Shell :: powershell function resize image 
Shell :: viewing ubuntu desktop from windows in the same network 
Shell :: symfony skeleton version 
Shell :: exit docker container 
Shell :: gcloud add role to service account 
Shell :: uninstall g2o 
Shell :: Make a backup of the database with SSH 
Shell :: list pid bash 
Shell :: shell count number of columns 
Shell :: docker db instance workbench connection 
Shell :: teamcity set environment variable command line 
Shell :: download file on linus ssh 
Shell :: get container config docker 
Shell :: wpa_supplicant connect to wifi 
Shell :: docker run commands 
Shell :: mysql connect another port 
Shell :: copying folders in git bash 
Shell :: git untract file 
Shell :: command to create jpeg in linux 
Shell :: time is not updating from internet ubuntu 
Shell :: how to update old branch 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =