Commit ed8877c9 authored by Ben Anderson's avatar Ben Anderson

Shell scripts

parents
File added
#!/bin/sh
INPUT=$(sort -t , -k 5 "./timesheet.csv")
echo 'Customer : Hours'
currentSum=0
currentCompany='ABC Travel'
awk -F, -v sum=$currentSum -v company=$currentCompany '{
print $5
print company " " sum
if ($5 != company) {
print company " : " sum
company=$5
sum=$8
} else {
sum=sum+$8
}
}' <<< "$INPUT"
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
1,Apple,Color is Red
2,Mango,Color is Orange
3,Banana,Color is Yellow
#!/bin/sh
PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
# echo `pwd`
INPUT=$PARENT_PATH"/input/sample.txt"
IFS=$'\n'
for line in $(awk -F, '{ print $1 "," "\"" $2 "\"" "," "\"" $3 "\"" }' $INPUT); do
echo "insert into myfruits (code,name,color) values ($line)"
done
# awk -F, ' { "" }' $INPUT
# awk -F, '{ print $3","$4" }' $INPUT
This diff is collapsed.
#!/bin/bash
for num in $(seq 1 2 51); do
let "rem=num % 2"
if [[ $rem -eq 1 ]]; then echo -n "$num"; fi
done
\ No newline at end of file
#!/bin/sh
name=$1
usersList='/etc/passwd'
echo $(awk -F: '$1 == '"$1"' { print "Home directory: " $6 }' $usersList)
\ No newline at end of file
This diff is collapsed.
#!/bin/bash
for arg in $@; do
if test -f "$arg"; then
echo ${arg^^}
fi
done
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