About shell script

ksh timestamp:

date '+%Y-%m-%d-%H.%M.%S.%N'

suggest to user timestamp rather than date value as the suffix of the the script logs because the date value could be duplicated within one day.
For example, script A exports data into a shared file and job B and C, which share the same load script, load the exported data into database, if the suffix of the target log is date, there will be collision.
The same example, if job B and C have different inputted table names, it is not suggest to put the table names into a file to handle, even if the file have timestamp as the suffix to avoid collision, because timestamp may be the same, too. Try to handle multiple values by array.
Writing to a shared file may lead to collision and better to store application private data into its own data structure.

ksh array

  • indexed array

initiate:

set -A characters Mugen Jin Fuu

To print first value, enter:

echo ${characters[0]}

To count number of items in an array called characters, enter:

echo ${#characters[@]}

You can use for loop as follows to iterate through all values:

for i in ${characters[@]}; do echo "Samurai Champloo character - $i"; done

猜你喜欢

转载自blog.csdn.net/weixin_38061610/article/details/88943370