welcome: please sign in
location: Shell

Shell

Geschichte

In the near beginning there was the Bourne shell /bin/sh (written by S. R. Bourne). It had (and still does) a very strong powerful syntactical language built into it, with all the features that are commonly considered to produce structured programs; it has particularly strong provisions for controlling input and output and in its expression matching facilities. But no matter how strong its input language is, it had one major drawback; it made nearly no concessions to the interactive user (the only real concession being the use of shell functions and these were only added later) and so there was a gap for something better.

Beispiele

if [ `whoami` != "root" ];then
    echo "lam0r"
else
    echo -n "checking....."
    sleep 2
    echo "ok - the owner of the system"
fi

exit 0

Hier nochmal Piping, Backticks, For-Loops, If-Abfragen, und arithmetische Ausdrücke:

for pid in `ps h -eo pid -U $USER|sort -n`; do
  printf "%6d gehoert $USER" $pid
  info=`ps h -o user -p $((pid+1))`
  # Für weitere if-Bedingungen siehe "man test"
  if [ ! -z "$info" ]; then
    printf "%6d+1 gehoert %s\n" $pid $info
  else
    echo
  fi
done

Shell (last edited 2008-07-14 09:55:46 by localhost)