quote-fetch.sh

来自「Shall高级编程」· Shell 代码 · 共 41 行

SH
41
字号
#!/bin/bash# quote-fetch.sh: Download a stock quote.E_NOPARAMS=66if [ -z "$1" ]  # Must specify a stock (symbol) to fetch.  then echo "Usage: `basename $0` stock-symbol"  exit $E_NOPARAMSfistock_symbol=$1file_suffix=.html# Fetches an HTML file, so name it appropriately.URL='http://finance.yahoo.com/q?s='# Yahoo finance board, with stock query suffix.# -----------------------------------------------------------wget -O ${stock_symbol}${file_suffix} "${URL}${stock_symbol}"# -----------------------------------------------------------# To look up stuff on http://search.yahoo.com:# -----------------------------------------------------------# URL="http://search.yahoo.com/search?fr=ush-news&p=${query}"# wget -O "$savefilename" "${URL}"# -----------------------------------------------------------# Saves a list of relevant URLs.exit $?# Exercises:# ---------## 1) Add a test to ensure the user running the script is on-line.#    (Hint: parse the output of 'ps -ax' for "ppp" or "connect."## 2) Modify this script to fetch the local weather report,#+   taking the user's zip code as an argument.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?