2938.js 1.4 KB

12
  1. "use strict";(self.webpackChunkmy_application=self.webpackChunkmy_application||[]).push([[2938],{2938:(e,n,i)=>{i.r(n),i.d(n,{default:()=>t});const t='#!/bin/bash\n# Simple line count example, using bash\n#\n# Bash tutorial: http://linuxconfig.org/Bash_scripting_Tutorial#8-2-read-file-into-bash-array\n# My scripting link: http://www.macs.hw.ac.uk/~hwloidl/docs/index.html#scripting\n#\n# Usage: ./line_count.sh file\n# -----------------------------------------------------------------------------\n\n# Link filedescriptor 10 with stdin\nexec 10<&0\n# stdin replaced with a file supplied as a first argument\nexec < $1\n# remember the name of the input file\nin=$1\n\n# init\nfile="current_line.txt"\nlet count=0\n\n# this while loop iterates over all lines of the file\nwhile read LINE\ndo\n # increase line counter\n ((count++))\n # write current line to a tmp file with name $file (not needed for counting)\n echo $LINE > $file\n # this checks the return code of echo (not needed for writing; just for demo)\n if [ $? -ne 0 ]\n then echo "Error in writing to file ${file}; check its permissions!"\n fi\ndone\n\necho "Number of lines: $count"\necho "The last line of the file is: `cat ${file}`"\n\n# Note: You can achieve the same by just using the tool wc like this\necho "Expected number of lines: `wc -l $in`"\n\n# restore stdin from filedescriptor 10\n# and close filedescriptor 10\nexec 0<&10 10<&-'}}]);
  2. //# sourceMappingURL=2938.js.map