⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 script-detector.sh

📁 一本完整的描述Unix Shell 编程的工具书的所有范例
💻 SH
字号:
#!/bin/bash# script-detector.sh: Detects scripts within a directory.TESTCHARS=2    # Test first 2 characters.SHABANG='#!'   # Scripts begin with a "sha-bang."for file in *  # Traverse all the files in current directory.do  if [[ `head -c$TESTCHARS "$file"` = "$SHABANG" ]]  #      head -c2                      #!  #  The '-c' option to "head" outputs a specified  #+ number of characters, rather than lines (the default).  then    echo "File \"$file\" is a script."  else    echo "File \"$file\" is *not* a script."  fidone  exit 0#  Exercises:#  ---------#  1) Modify this script to take as an optional argument#+    the directory to scan for scripts#+    (rather than just the current working directory).##  2) As it stands, this script gives "false positives" for#+    Perl, awk, and other scripting language scripts.#     Correct this.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -