前のエントリーで御礼した、tohokuaikiさんのエントリーの最後に:
あ、コマンド区切り「;」とかよく分からんね。使ったことないし。
例で説明しましょうか。
例えば、次のようなシェルスクリプトを考えます。
#! /bin/sh
the_file=/var/tmp/WathchMe
if [ ! -e $the_file ]
then touch $the_file
fi
echo -n "the size of $the_file: "
ls -l $the_file | sed -e 's/ */ /g' | cut -d ' ' -f 5
これ、6行ありますが、1行にまとめて書けます。各行の終わりにセミコロンをはさみながらズラズラと横に並べてもいいんです。
$ the_file=/var/tmp/WathchMe; if [ ! -e $the_file ]; then touch $the_file; fi;\
echo -n "the size of $the_file: "; ls -l $the_file | sed -e 's/ */ /g' | cut -d ' ' -f 5
さすがに長いので行継続の「\」入れて2行にしましたが、ほんとに1行でもかまいません。
とまー、セミコロンの使い方はこんなです。