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 :: git update comment 
Shell :: pip3 install from git 
Shell :: debian full install qt5 
Shell :: yarn check package version 
Shell :: We no longer support global installation of Create React App. 
Shell :: git check which files are committed 
Shell :: git show files modified since commit 
Shell :: git global noverify 
Shell :: android create keystore command line 
Shell :: aac anticheat 
Shell :: server 2012r2 powershell unable to download from URI 
Shell :: delete pid port 
Shell :: install sqlite in ubuntu 
Shell :: git sync branches 
Shell :: install torch 
Shell :: vuforia git url 
Shell :: where is ubuntu home directory on windows 
Shell :: cudnn version linux 
Shell :: wget git bash 
Shell :: while loop shell script 
Shell :: ubuntu command get my ip 
Shell :: ssh raspberryp 
Shell :: linkedin pc download on ubuntu 
Shell :: uvicorn ERROR: [Errno 98] Address already in use 
Shell :: shell trim 
Shell :: how to install wsl 2 in windows 10 
Shell :: bash "set -e" 
Shell :: bash split string into variables 
Shell :: loop file bash 
Shell :: how to update linux 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =