Created
July 2, 2014 10:19
-
-
Save anonymous/e8ab3e666132164c5dc5 to your computer and use it in GitHub Desktop.
prices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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