-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfile.functions
58 lines (49 loc) · 1.36 KB
/
file.functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# This file is part of shellfire core. It is subject to the licence terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/core/master/COPYRIGHT. No part of shellfire core, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
# Copyright © 2014-2015 The developers of shellfire core. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/core/master/COPYRIGHT.
core_usesIn core temporaryFiles
core_dependency_requires '*' awk
core_file_characterByCharacter()
{
local filePath="$1"
shift 1
local TMP_FILE
core_temporaryFiles_newFileToRemoveOnExit
local singleCharactersFile="$TMP_FILE"
core_file_characterByCharacterCreate "$filePath" "$singleCharactersFile"
local callback
local character
{
while IFS='' read -r character
do
for callback in "$@"
do
$callback
done
done
} <"$singleCharactersFile"
rm -f "$singleCharactersFile"
}
core_file_characterByCharacterCreate()
{
local inputFile="$1"
local outputFile="$2"
awk '
BEGIN {
srand()
FS=""
RS="n/o/m/a/t/c/h" rand()
}
{
for (i = 1; i <= NF; i++)
{
if ($i ~ /\n/)
{
printf "\n"
}
else
{
print $i
}
}
}' <"$inputFile" >"$outputFile"
}