Commit 54e869b5 authored by Khai Yuan ​Liew's avatar Khai Yuan ​Liew

Assignments complete

parents
#!/bin/bash
line=$(awk -F, '{ print "insert into myfruits \(code,name,color\) values \("$1",\""$2"\",\""$3"\"\)" }' sample.txt)
echo "$line"
#!/bin/bash
filename='/etc/passwd'
input=$1
found=false
while IFS=":" read -r username password uid gid uidinfo directory command
do
if [ $input == $username ] ; then
echo "Home directory: $directory"
found=true
break
fi
done < $filename
if [ $found == false ] ; then
echo "User \"$input\" not found"
fi
#!/bin/bash
for file in $@
do
echo "${file^^}"
done
#!/bin/bash
for number in {1..50..2}
do
echo "Number is : $number"
done
#!/bin/bash
result=$(awk -F, 'BEGIN{print "Customers : Hours"}
{if ($7 == "Y") sum[$5]+=sprintf("%.1f",$8);}
END{for(i in sum) printf "%s : %.1f\n", i, sum[i];}' timesheet.csv)
echo "$result"
total=$(awk -F, '{if($7 == "Y") sum+=$8;}
END{printf "Total : %.1f\n", sum;}' timesheet.csv)
echo "$total"
1,Apple,Color is Red
2,Mango,Color is Orange
3,Banana,Color is Yellow
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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