Changes between Version 1 and Version 2 of jazz/10-07-22


Ignore:
Timestamp:
Jul 22, 2010, 4:26:45 PM (14 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • jazz/10-07-22

    v1 v2  
     1= 2010-07-22 =
     2
     3 * [備忘] 重新改用 root 身份執行的 shell script
    14{{{
     5#!sh
    26[ "`id -u`" != "0" ] && exec sudo su -c "$0" "$@"
    37}}}
     8 * [備忘] 讓標準輸出(STDOUT)與標準錯誤(STDERR)導入到 log 檔的 bash script 寫法
    49{{{
     10#!sh
     11#! /bin/bash
     12
     13TARGET="target-file"
     14
     15# file descriptor 4 prints to STDOUT and to TARGET
     16exec 4> >(while read a; do echo $a; echo $a >>$TARGET; done)
     17
     18# now STDOUT is redirected
     19exec >&4
     20exec 2>&4
     21date
     22echo "Date sent to fd4."
     23abc
     24
    525}}}