Changes between Version 14 and Version 15 of YM_Course_2009/Lab4


Ignore:
Timestamp:
Jul 4, 2009, 4:41:48 PM (15 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • YM_Course_2009/Lab4

    v14 v15  
    202202file0, fileA 均不存在
    203203}}}
     204
     205== Shell Script 範例 ==
     206
     207{{{
     208$ cat > test1.sh << EOF
     209#!/bin/bash
     210echo "Enter a filename: "
     211read filename
     212if [ ! –r "$filename" ]
     213 then
     214   echo "File is not read-able"
     215 exit 1
     216fi
     217EOF
     218$ chmod a+x test1.sh
     219$ ./test1.sh
     220}}}
     221
     222{{{
     223$ cat > test2.sh << EOF
     224#! /bin/bash
     225
     226if [ $# -lt 1 ]; then
     227        echo "Usage: filetest filename"
     228        exit 1
     229fi
     230if [[ ! -f "$1" || ! -r "$1" || ! -w "$1" ]]
     231then
     232  echo "File $1 is not accessible"
     233  exit 1
     234fi
     235EOF
     236$ chmod a+x test2.sh
     237$ ./test2.sh
     238}}}