Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

8.3 disk 3

Shulou Source: shulou.com Published: 2022-06-03 07:45:50 09月23日 Update

Modify in the previous section:

For I in `seq 0 $# `; do

If [$#-gt 0]; then

Case

Esac

Fi

Review:

$0 the file name of the current script

Parameters passed to a script or function

$# number of parameters passed to the script or function

$* all parameters passed to the script or function

All parameters passed to the script or function by $@. When enclosed in double quotes ("")

Slightly different from $*

$? The exit status of the last command, or the return value of the function

$the current Shell process ID. For Shell scripts, it is the process ID in which these scripts are located

Exercise: write a script showlogged.sh whose usage format is:

Showlogged.sh-v-o-h |-- help

Where the-h option can only be used alone to display help information

The-c option displays the number of all users logged in on the current system

If the-v option is used at the same time, both the number of users logged in at the same time and the number of users logged in are displayed.

Information about the logged-in user; such as

Logged users:4.

They are:

Root tty2 Feb 18 02:41

....

Vim showlogged.sh

#! / bin/bash

#

Declare-I SHOWNUM=0

Declare-I SHOWUSERS=0

For I in `seq 1 $# `; do

If [$#-gt 0]; then

Case $1 in

-h |-- help)

Echo "Usage: `basename $0`-h |-- help-c |-- count-v | 00verbose" `

Exit 0

-v |-- verbose)

Let SHOWUSERS=1

Shift

-c |-- count)

Let SHOWNUM=1

Shift

*)

Echo "Usage: `basename $0`-h |-- help-c |-- count-v | 00verbose" `

Exit 7

Esac

Fi

Done

If [$SHOWNUM-eq 1]; then

Echo "logged users: `who | wc-l`."

If [$SHOWUSER-eq 1]; then

Echo "They are:"

Who

Fi

Fi

Disk Management:

Mechanical hard disk

U disk CD floppy disk hard disk tape

Solid

Partition partition

To create a separate file system

MBR Master Boot record (512Byte for track 0)

Master Boot Record

Main Boot Record

Divide it into 3 segments:

446bytes:BootLoader program

64bytes:

Identify a partition every 16 bytes

2bytes: Magic Number

Whether the tag MBR is valid

Primary + extended partition

Tags: File link script directory disk function parameter system size number of times user login different number information and at the same time file name number of users hard disk Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux Huawei vpn OPPO Reno