Bo's Oracle Station

查看: 1869|回复: 0

课程第5次

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2019-7-14 21:19:41 | 显示全部楼层 |阅读模式
2019-07-14

在“”HOWTO“”文档目录中找例子:

[root@desktop3 doc]# find ./  -name "EXAMPLE*" -o -name "example*" -o -name "Example*" -type d
./libpng-1.5.13/example.c
./which-2.20/EXAMPLES
./mpfr-3.1.1/mpfr/examples
./perl-Filter-1.49/examples
./perl-Getopt-Long-2.40/examples
./bc-1.06.95/Examples
./krb5-libs-1.15.1/examples
./pygobject2-2.28.6/examples
./python-dateutil-1.5/example.py
./python-slip-0.4.0/dbus/example
./python-slip-0.4.0/dbus/example/example-conf-client.py
./python-slip-0.4.0/dbus/example/example-conf-mechanism.py
./python-magic-5.11/example.py
./nmap-ncat-6.40/examples
./python-pycurl-7.19.0/examples
./gnupg2-2.0.22/examples
./pygpgme-0.3/examples
./PyYAML-3.10/examples
./PyYAML-3.10/examples/pygments-lexer/example.yaml
./dbus-1.10.24/examples
./dbus-1.10.24/examples/example-session-disable-stats.conf
./dbus-1.10.24/examples/example-system-enable-stats.conf
./qt5/global/includes/examples-run.qdocinc
./initscripts-9.49.46/examples
./python-slip-dbus-0.4.0/example
./python-slip-dbus-0.4.0/example/example-conf-client.py
./python-slip-dbus-0.4.0/example/example-conf-mechanism.py
./wpa_supplicant-2.6/examples
./NetworkManager/examples
./teamd-1.27/example_configs
./teamd-1.27/example_ifcfgs
./pycairo-1.8.10/examples
./python-hwdata-1.7.3/example.py
./libreswan-3.25/examples
./python-blivet-0.61.15.72/examples
./vdo/examples
./avahi-0.6.31/example.service
./postfix-2.10.1/examples
./smartmontools-6.5/examplescripts
./sudo-1.8.23/examples
./vsftpd-3.0.2/EXAMPLE
-------------------------------------------------------
标准输入在键盘:
  1. [root@server3 ~]# tr [a-z] [A-Z]
  2. this is good
  3. THIS IS GOOD
  4. quit
  5. QUIT
  6. ^C
  7. [root@server3 ~]# tr -d [:blank:]
  8. this is good
  9. thisisgood
复制代码
----------------------------------------------------输入、输出和出错的复杂例子:
  1. [root@server3 labs]# ls -l RH124-4-1.txt  botang.txt  &> RH124-4-7.txt
  2. [root@server3 labs]# cat RH124-4-7.txt
  3. ls: cannot access botang.txt: No such file or directory
  4. -rw-r--r--. 1 root root 14 Jul 14 22:10 RH124-4-1.txt
  5. [root@server3 labs]# ls -l RH124-4-1.txt  botang.txt  & > RH124-4-8.txt
  6. [1] 73948
  7. [root@server3 labs]# ls: cannot access botang.txt: No such file or directory
  8. -rw-r--r--. 1 root root 14 Jul 14 22:10 RH124-4-1.txt

  9. [1]+  Exit 2                  ls --color=auto -l RH124-4-1.txt botang.txt
  10. [root@server3 labs]# cat RH124-4-8.txt
  11. [root@server3 labs]#  ls -l RH124-4-1.txt  botang.txt  & | grep botang
  12. -bash: syntax error near unexpected token `|'
  13. [root@server3 labs]#  ls -l RH124-4-1.txt  botang.txt  2>&1 |   grep botang
  14. ls: cannot access botang.txt: No such file or directory
  15. [root@server3 labs]# ls
  16. RH124-4-1.txt  RH124-4-3.txt  RH124-4-5.txt  RH124-4-7.txt
  17. RH124-4-2.txt  RH124-4-4.txt  RH124-4-6.txt  RH124-4-8.txt
  18. [root@server3 labs]# fdisk /dev/sda
  19. Welcome to fdisk (util-linux 2.23.2).

  20. Changes will remain in memory only, until you decide to write them.
  21. Be careful before using the write command.


  22. Command (m for help): L

  23. 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
  24. 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
  25. 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
  26. 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
  27. 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
  28. 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
  29. 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
  30. 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
  31. 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
  32. 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
  33. a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
  34. b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
  35. c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
  36. e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
  37. f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
  38. 10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
  39. 11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
  40. 12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
  41. 14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
  42. 16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
  43. 17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
  44. 18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
  45. 1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
  46. 1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
  47. 1e  Hidden W95 FAT1 80  Old Minix

  48. Command (m for help): q

  49. [root@server3 labs]# fdisk /dev/sda <<EOF
  50. > L
  51. > q
  52. > EOF
  53. Welcome to fdisk (util-linux 2.23.2).

  54. Changes will remain in memory only, until you decide to write them.
  55. Be careful before using the write command.


  56. Command (m for help):
  57. 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
  58. 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
  59. 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
  60. 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
  61. 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
  62. 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
  63. 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
  64. 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
  65. 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
  66. 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
  67. a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
  68. b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
  69. c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
  70. e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
  71. f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
  72. 10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
  73. 11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
  74. 12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
  75. 14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
  76. 16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
  77. 17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
  78. 18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
  79. 1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
  80. 1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
  81. 1e  Hidden W95 FAT1 80  Old Minix

  82. Command (m for help):
  83. [root@server3 labs]#
复制代码
关于多行标准输入的shell编程方法:
  1. #!/bin/sh

  2.       fdisk /dev/sda <<-EOF
  3.      L
  4.       q
  5.       EOF

复制代码
--------------------------------------
  1. #!/bin/sh

  2. read -p "Pls input a number: "  V1

  3. if [ $V1 -lt 10 ]
  4. then
  5. V2=$[ $V1 * 8 ]
  6. else
  7. V2=$[ $V1 * 4 ]
  8. fi

  9. echo $V2
  10. echo $V2 >/tmp/RH124-4-11.tmp

复制代码






回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-12-4 16:32 , Processed in 0.032636 second(s), 24 queries .

快速回复 返回顶部 返回列表