Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,5 @@
string='Hello,How,Are,You,Today'
(IFS=,
printf '%s.' $string
echo)

View file

@ -0,0 +1,58 @@
#! /bin/bash
stripchar-l ()
#removes the specified character from the left side of the string
#USAGE: stripchar "stuff" "s" --> tuff
{
string="$1";
string=${string#"$2"};
echo "$string"
}
join ()
#join a string of characters on a specified delimiter
#USAGE: join "1;2;3;4" ";" "," --> 1,2,3,4
{
local result="";
local list="$1";
OLDIFS="$IFS";
local IFS=${2-" "};
local output_field_seperator=${3-" "};
for element in $list;
do
result="$result$output_field_seperator$element";
done;
result="`stripchar-l "$result" "$output_field_seperator"`";
echo "$result";
IFS="$OLDIFS"
}
split ()
{
#split a string of characters on a specified delimiter
#USAGE: split "1;2;3;4" ";" --> 1 2 3 4
local list="$1";
local input_field_seperator=${2-" "};
local output_field_seperator=" ";
#defined in terms of join
join "$list" "$input_field_seperator" "$output_field_seperator"
}
strtokenize ()
{
#splits up a string of characters into tokens,
#based on a user supplied delimiter
#USAGE:strtokenize "1;2;3;4" ";" ":" --> 1:2:3:4
local list="$1";
local input_delimiter=${2-" "};
local output_delimiter=${3-" "};
local contains_a_space=" "; #added to highlight the use
#of " " as an argument to join
#splits it input then joins it with a user supplied delimiter
join "$( split "$list" "$input_delimiter" )" \
"$contains_a_space" "$output_delimiter";
}

View file

@ -0,0 +1,2 @@
strtokenize "Hello,How,Are,You,Today" "," "."
Hello.How.Are.You.Today

View file

@ -0,0 +1,13 @@
string1="Hello,How,Are,You,Today"
elements_quantity=$(echo $string1|tr "," "\n"|wc -l)
present_element=1
while [ $present_element -le $elements_quantity ];do
echo $string1|cut -d "," -f $present_element|tr -d "\n"
if [ $present_element -lt $elements_quantity ];then echo -n ".";fi
present_element=$(expr $present_element + 1)
done
echo
# or to cheat
echo "Hello,How,Are,You,Today"|tr "," "."