-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneric_operations.sh
executable file
·44 lines (39 loc) · 1.03 KB
/
generic_operations.sh
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
#!/bin/bash
names=$1;
instruction=$2;
exe=$3;
IFS= read -d '' usage << "EOF"
usage: ./generic_operations.sh file 'command'\\n
\\n
examples:\\n
\\t./generic_operations.sh name.txt 'echo \"ln -s \$first \$second\"'\\n
\\t./generic_operations.sh name.txt 'ln -s \$first \$second\'\\n
EOF
if [[ $names == "" || $names == "-h" || $names == "--help" ]]; then
echo -e $usage;
exit 1;
fi
# if [[ $exe == "" ]]; then
# $exe=0;
# fi
# while IFS='' read -r line || [[ -n "$line" ]]; do
while IFS=$'\t' read -r first second
do
# printf "%s", $first
if [[ ! -z "${first// }" ]]; then
eval $instruction
# echo
fi
# echo "Text read from file: $line"
# first=$(echo -e $line | cut -d " " -f1);
# second=$(echo -e $line | cut -d " " -f2);
# instruction="ls -lh $first";
# instruction="mv $first $second";
# if [[ $exe == 1 ]]; then
# echo executing $instruction;
# $instruction
# # else
# # echo $instruction;
# fi
# eval $instruction
done <"$names"