Issue
It is because the users do not know how to use vi, I need to create a solution to let the user create a file in the AIX server using a copy and paste.
I refer to the solution from the below link:
How to read multi-line input in a Bash script?
I create a script as below:
#!/bin/bash
echo "Paste the Bulletin:"
IFS= read -d '' -n 1 keyvariable
while IFS= read -d '' -n 1 -t 2 c
do
keyvariable+="$c"$'\n'
done
echo $keyvariable >abc.txt
echo "Thanks!"
The input:
sdsdfsdfsd
4354353453
/*-/*/-/--/`
Expected the abc.txt content:
sdsdfsdfsd
4354353453
/*-/*/-/--/
Actual the abc.txt content:
sd s d f s d f s d 4 3 5 4 3 5 3 4 5 3 /*- /* /-/- - /
Unfortunately, the line breaks in the original text do not preserve, so how can I preserve the line breaks and then write the text to the output file?
Solution
If you have bash on your AIX, then you can try this:
#!/bin/bash
echo "Paste the Bulletin:"
while IFS= read -r -t 2 c
do
keyvariable+="$c"$'\n'
done
echo "$keyvariable" >abc.txt
echo "Thanks!"
Answered By - Lorinczy Zsigmond