Commit 72844989 authored by Kevin Kaminski's avatar Kevin Kaminski

Add 3 completed bash programs

parents
#!/bin/bash
name="Kevin"
if [ $name == "Kevin" ]
then echo "Hello, $name"
fi
#########################################################################
PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
for file in *
do
echo "File ${file^^}"
[[ -f $file ]] && cp $file /tmp/${file^^}
done
##########################################################################
#!/bin/bash
declare -i totalhours=0
while read LINE
do
billFlag=$(echo $LINE | awk -F, '{ print $7 }')
hours=$(echo $LINE | awk -F, '{ print $8}')
[[ $billFlag == "Y" ]] && totalhours=$(( $totalhours + $hours ))
done < ./timesheet.csv
echo "Total hours: $totalhours"
##########################################################################
#!/bin/bash
declare -i totalhours=0
while read LINE
do
IFS=, read -r start end name email project country billFlag hours <<< "${LINE}"
#hours=$(echo $LINE | awk -F, '{print $8}')
[[ $billFlag == "Y" ]] && totalhours=$(( $totalhours + $hours ))
done < ./timesheet.csv
echo "Total hours $totalhours"
#!/bin/bash
fileName="sql-output.txt"
while read LINE
do
code=$(echo $LINE | awk -F, '{ print $1 }')
name=$(echo $LINE | awk -F, '{ print $2 }')
color=$(echo $LINE | awk -F, '{ print $3 }')
# echo "$code"
# echo "$name"
# echo "$color"
sql="insert into myfruits (code, name, color) values ($code,\"$name\",\"$color\")"
echo $sql
done < ./sample.txt
# echo "Total hours $totalhours"
#!/bin/bash
num=1
while [ $num -lt 50 ]
do
echo "Number is : " $num
num=$(($num+2))
done
\ No newline at end of file
#!/bin/bash
printf "Home directory: "
eval echo ~$1
\ No newline at end of file
1,Apple,Color is Red
2,Mango,Color is Orange
3,Banana,Color is Yellow
#!/bin/bash
for var in "$@"
do
echo "$var"
done
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment