项目作者: Vipul1142

项目描述 :
Implementing head and tail functionality in Node.js
高级语言: JavaScript
项目地址: git://github.com/Vipul1142/head-tail-OfShell-inJS.git
创建时间: 2020-04-11T18:11:32Z
项目社区:https://github.com/Vipul1142/head-tail-OfShell-inJS

开源协议:

下载


HEAD and TAIL funtionality of terminal in Node.js

tead is a command in shell(terminal) to print first n lines of referenced file.

  • synopsis head -nN filename
    tail is a command in shell(terminal) to print first n lines of referenced file.
  • synopsis tail -nN filename

Input for the file could be in any one of the following syntax.

  • node head.js file.txt -> print first 10 lines of the given file.
  • node head.js NOFILE -> Print “head: cannot open ‘NOFILE’ for reading: No such file or directory”.
  • node head.js -N file.txt -> Print first N lines of the given file.
  • node head.js -N NOFILE -> Print “head: cannot open ‘NOFILE’ for reading: No such file or directory”.
  • node head.js -a file.txt -> Print “head: invalid number of lines: ‘a’”.
  • node head.js -nN file.txt -> Print first N lines of the given file.
  • node head.js -nN NOFile -> Print “head: cannot open ‘NOFILE’ for reading: No such file or directory”.
  • [x] node head.js -na file.txt -> Print “head: invalid number of lines: ‘a’”.

  • [x] node tail.js file.txt -> print last 10 lines of the given file.

  • node tail.js NOFILE -> Print “tail: cannot open ‘NOFILE’ for reading: No such file or directory”.
  • node tail.js -N file.txt -> Print last N lines of the given file.
  • node tail.js -N NOFILE -> Print “tail: cannot open ‘NOFILE’ for reading: No such file or directory”.
  • node tail.js -a file.txt -> Print “tail: invalid number of lines: ‘a’”.
  • node tail.js -nN file.txt -> Print last N lines of the given file.
  • node tail.js -nN NOFile -> Print “tail: cannot open ‘NOFILE’ for reading: No such file or directory”.
  • node tail.js -na file.txt -> Print “tail: invalid number of lines: ‘a’”.