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

From thelinuxwiki
Jump to: navigation, search
 
Line 3: Line 3:
 
# get input from user via CLI
 
# get input from user via CLI
 
echo "Paste input..."
 
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