BAEL-3370: Some more examples

This commit is contained in:
Sorin Zamfir 2019-12-03 20:56:35 +02:00
parent 57934f602c
commit d64771257a
2 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,2 @@
lorem;ipsum;is\;simply\;du\mmy;text
of;the;printing;and;typesetting;industry.
1 lorem ipsum is\ simply\ du\mmy text
2 of the printing and typesetting industry.

View File

@ -35,6 +35,7 @@ file_read(){
do
echo " Word [$input]"
done
# close file descriptor after reading
exec {file_descriptor}>&-
}
@ -67,13 +68,46 @@ advanced_pipeing(){
}
custom_ifs_read(){
declare -a input_array
while IFS=";" read -a input_array -r
do
for element in ${input_array[@]}
do
echo -n "$element.backup "
done
echo ""
done < "file.csv"
}
infinite_read(){
while read -d "?" -ep "Input:" input
do
echo "$input"
done
}
custom_ifs(){
declare -a input_array
IFS=$1 # whitespace
read -a input_array -p "Enter something with delimiter <$1>:"
for input in ${input_array[@]}
do
echo "[$input]"
done
}
#default_read
#array_read
#special_delim
#file_read
#prompt_read
#default_input_read
advanced_pipeing
#advanced_pipeing
#custom_ifs_read
#infinite_read
custom_ifs " "
custom_ifs ";"