<file_sep>#!/bin/bash
#validAlphaNum--Ensures that input consist only of alphabetical
#  and numer characters

valid(){

	#Valide arg: returns 0 if all uper+lover+digits; 1 otherwise

	#remove all unacceptable hars.
	validchars="$(echo $1 | sed -e 's/[^[:alphanum:]]//g')"
		

}
<file_sep>#!/bin/bash

#This programm checks out, if the wanted Programm exists in the Path or not

#inpath--Verifies that a specified programm is either valid as is
# or can be found in the PATH directory list


in_path()
{
	#given a command and the PATH, tries to find the command. Returns 0 if
	# found and executable; 1 if not. Note that this temporarily modifies 
	# the IFS(internal field seperator) but restores it upon completion
	
	cmd=$1	ourpath=$2 result=1

	oldIFS=$IFS	IFS=":"

	for directory in "$ourpath"
	do
		if [ -x $directory/$cmd ] ; then
			result=0		#if we're here, we found the command.
		fi 	
	done

	IFS=$oldIFS
	return $result	
			
}


checkForCmdInPath()
{
	var=$1

	if [ "$var" != "" ] ; then
		if [ "${var:0:1}" = "/" ] ; then
			if [ ! -x $var ]; then
				return 1
			fi
		elif ! in_path $var "$PATH"; then
			return 2
		fi
	fi
}


#The only thin now is missing is the dialog skript to insert the input for the needed functions

# Script input handeling

#Check if amount of arguments is valid

if  [[ $# -ne 1 ]] ; then
	echo "The syntax of the function is: $0 cmd or path, but only one argument" >&2
	exit 1
fi


#if the input was valid calculate the output an return it


checkForCmdInPath $1 

#Do a case szenario where you can choose between all the three options

case $? in 
	0 ) 
	       echo " The program $1 is in the path and it is executable"	
		;;
	1 )
	       echo " The programm $1 has not been found or is not executable "	
		;;
	2 ) 
		echo " The programm $1 is not found in PATH"	
		;; 













<file_sep># bash-and-vim

I started programming a while ago but was always switching between different IDE's. Now I have decided to switch and stay by vim. I want to use my own vim modifications everywhere, so i make a repo for this one. 

Else I switched to Ubuntu recently why I thought, that it would be great to learn a bit of bash. I don't think that i need much space for bash nor for vim. So I put both elements in the same repository
<file_sep>#!/bin/bash


#This script uses the bc function to compute arbitraty prcision floating point
#Calculations


# Main function


 python << EOF
	$1	
	quit()
	EOF

exit 0
<file_sep>#!/bin/bash

#nicenumber takes any number inputed by the syntax of:  integer.decimal  or integer  or .decimal  
#and process the number in a manner, that the representation of the number is easy to read


#######################
# nice number function#
#######################
nicenumber(){
		
	integer=$(echo $1| cut -d. -f1)
	decimal=$(echo $1| cut -d. f2)
	
	#Check if number has more than the integer part.
	if [ "$decimal" != $1 ]; then
		result="${DD:= '.'}$decimal"
	fi
	
	thousands=$integer


	#Main Part of the Programm is this while loop
	while [[ $thousands -gt 999 ]]; do
		remainder=$(($thousands % 1000))            #3 least significant digits	

		#We need remainer to bee three digits. Do we need to add zeros?
		while [[ ${#remainder} -lt 3 ]] ; do #Force leading zeros
			dremainder="0$remainder"
		done
		
		result="${TD:=","}${remainder}${result}"   #Builds right to left
		thousands=$(($thousands / 1000)) 	   #To left of reaminder, if any
	done

	nicenum="${thousands}${result}"	
	if [[ ! -z $2 ]] ; then
		echo $nicenum
	fi
	}


##Global Definition of the Delimiters
	
	DD="."   #Decimal point Delimiters, to seperate whole and fractional values
	TD=","   # Thousands delimiter, to separate every three digits


#=================
#Begin Main Script
#=================

while getopts "d:t" opt; do
	case $opt in
		d ) DD="$OPTARG" ;;
		t ) TD="$OPTARG" ;;
	esac
done

shift (($OPTIND -1))

#Input Validation
if [[ $# -eq 0 ]] ; then
	echo "Usage: $(basename $0) [-d c] [-t c] number"
	echo " -d specifies the decimal point delimiter"
	echo " -t specifies the thousands delimiter"
	exit 0
fi

nicenumber $1 1 #Second arg forces nicenumber to 'echo' output

exit 0






 
<file_sep>#!/bin/bash
#This script should normalize the dateformats



#Generate the function to normalize all the variables

#===========#
# Functions #
#===========#

# Functio that changes gives the mont as a 3 letter expression
monthNumToName()
	{
		#set the 'month' variable to the appropriate value.
		case $1 in 
			1 ) month="Jan" ;; 2 ) month="Feb";;
			3 ) month="Mar" ;; 4 ) month="Apr";;
			5 ) month="May" ;; 6 ) month="Jun";;
			7 ) month="Jul" ;; 8 ) month="Aug";;
			9 ) month="Sep" ;; 10 ) month="Oct";;
			11 ) month="Nov";; 12 ) month="Dec";;

			* ) echo "$0: Unknown month value $1" >&2
				exit 1
		esac

		return 0
	}

#==========================#
#Context for the Dialoge   #
#==========================#

#Error Check 1:
	if [[ $# -ne 3 ]]; then
		
		echo "Usage of $0: $0 month day year" >&2
		exit 1
	fi


#Error Check 2: test: number >= 999
	if [[ $3 -le 999 ]]; then
	       echo "The year should be a 4 digit number, else it is WRONG" >&2
		exit 1
	fi


#Execute the algorithm planed

#Check if Month is inputed as number or word

	if [[ -z $(echo $1|sed -e 's/[[:digit:]]//g') ]]; then
		monthNumToName $1
	else
		#Normalize to first 3 Letters, first upper- and then lowercase.
		month="$(echo $1|cut -c1|tr '[:lower:]' '[:upper:]')"
		month="$month$(echo $1|cut -c2-3 | tr '[:upper:]' '[::lower]')"
	fi

	echo $month $2 $3

	exit 0

	
			






<file_sep>#!/bin/bash 

#I am not sure about a command so i write a scrit to check if I
#have understood everything right

sizeCheck()
{
#Declaration of the variables
	number=100


	if [[ $1 -gt $number ]]; then
		return 0
		
	elif [[ $1 -lt $number ]]; then 
		return 1
	else
		return 2
	fi
}



#Write the proper context for the function

#errorCheck
if [ $# -ne 1 ]; then
	echo "The syntax should be: $0 number , so try it again!!!!" >&2
	exit 1
fi

#Use the function to output if number is greater, smaller or equal 100
sizeCheck $1

case $? in 
	0 ) echo "The number is greater than 100" ;;
	1 ) echo "The number is smaller than 100" ;;
	2 ) echo "The number is 100" ;;
	* ) echo "System error" >&2 ;;
esac

exit 0
<file_sep>#!/bin/bash

#The IFS = Internal Field Seperator is there to seperatoe
#Words in strings. Per default it is whitespace and tab.
#If you want to split up words by another rule, you have to 
#change the IFS as you like it, so here is an example of two streams 
#for the IFS


#Coding example with regular IFS
mystring="Hell/oo/uuu/suc"
for word in $mystring; do
	echo "Word: $word"
done


#coding example with modified IFS

IFS="/"

for word in $mystring; do
	echo "Word: $word"
done
