Difference between revisions of "read multiline user input in bash"

From thelinuxwiki
Jump to: navigation, search
(Created page with "<source lang="bash"> # get input from user via CLI echo "Paste import config..." IFS= read -d '' -n 1 importvariable while IFS= read -d '' -n 1 -t 2 c do importvariable+=...")
 
 
(One intermediate revision by one user not shown)
Line 2: Line 2:
  
 
# get input from user via CLI
 
# get input from user via CLI
echo "Paste import config..."
+
echo "Paste input..."
IFS= read -d '' -n 1 importvariable
+
IFS= read -d '' -n 1 inputvariable
 
while IFS= read -d '' -n 1 -t 2 c
 
while IFS= read -d '' -n 1 -t 2 c
 
do
 
do
     importvariable+=$c
+
     inputtvariable+=$c
 
done
 
done
 
</source>
 
</source>

Latest revision as of 00:39, 2 November 2022

# get input from user via CLI
echo "Paste input..."
IFS= read -d '' -n 1 inputvariable
while IFS= read -d '' -n 1 -t 2 c
do
    inputtvariable+=$c
done