Skip to content

Instantly share code, notes, and snippets.

Created July 2, 2014 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e8ab3e666132164c5dc5 to your computer and use it in GitHub Desktop.
Save anonymous/e8ab3e666132164c5dc5 to your computer and use it in GitHub Desktop.
prices
[user]#vim prices.bash
#!/bin/bash -x
#echo "Enter product: "
#read product
#echo "Enter Quantity:"
#read quantity
#echo " Enter Company eg c1:"
#read company
product="monitor"
quantity="2"
case $product in
monitor)
prices=`awk -f prices.awk -v p="monitor" c="COMPANY2" prices.txt`
total_amount=$(($prices*$quantity))
echo "$total_amount"
;;
*)
echo bye; exit 0
;;
esac
[user]#vim prices.awk
NR=1 {
for(i=2; i < NF; i++)
{ if ($i == c) { cn = i; break; }}} $1 == p { print $cn; exit; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment