July 2018
Beginner
264 pages
8h 9m
English
Open a terminal and create a script named file-splitter.sh.
The following is the code snippet:
#!/bin/bashFNAME=""LEN=10TYPE="line" OPT_ERROR=0set -ffunction determine_type_of_file() { local FILE="$1" file -b "${FILE}" | grep "ASCII text" > /dev/null RES=$? if [ $RES -eq 0 ]; then echo "ASCII file - continuing" else echo "Not an ASCII file, perhaps it is Binary?" fi }
Next, run file-splitter.sh with this command and flags ( -i, -t, -l):
$ bash file-splitter.sh -i input-lines -t line -l 10
Review the output and see what the difference is with -t size and when -l line is used. What about when -l 1 or -l 100 is used? Remember to remove the split files using $ rm input-lines.*:
$ rm input-lines.*$ bash file-splitter.sh -i input-lines ...
Read now
Unlock full access