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

📄 find-splitpara.sh

📁 Shall高级编程
💻 SH
字号:
#!/bin/bash# find-splitpara.sh#  Finds split paragraphs in a text file,#+ and tags the line numbers.ARGCOUNT=1       # Expect one arg.E_WRONGARGS=65file="$1"        # Target filename.lineno=1         # Line number. Start at 1.Flag=0           # Blank line flag.if [ $# -ne "$ARGCOUNT" ]then  echo "Usage: `basename $0` FILENAME"  exit $E_WRONGARGSfi  file_read ()     # Scan file for pattern, then print line.{while read linedo  if [[ "$line" =~ ^[a-z] && $Flag -eq 1 ]]     then  # Line begins with lc character, following blank line.     echo -n "$lineno::   "     echo "$line"  fi  if [[ "$line" =~ "^$" ]]     then     #  If blank line,     Flag=1   #+ set flag.  else     Flag=0  fi  ((lineno++))done} < $file  # Redirect file into function's stdin.file_readexit $?# ----------------------------------------------------------------This is line one of an example paragraph, bla, bla, bla.This is line two, and line three should follow on next line, butthere is a blank line separating the two parts of the paragraph.# ----------------------------------------------------------------Running this script on a file containing the above paragraphyields:4::   there is a blank line separating the two parts of the paragraph.There will be additional output for all the other split paragraphsin the target file.

⌨️ 快捷键说明

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