-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnameCheck.sh
executable file
·40 lines (30 loc) · 1.03 KB
/
nameCheck.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
#!/bin/bash
if [ "$1" = "help" ] || [ -z "$1" ]
then
echo ""
echo "--------------------------------------------------------------------------------------------------------------------------"
echo " To run this script, use the following syntax:"
echo " bash $0 <delim,field> "
echo " comma spearated values for delimiter and field"
echo " simple example: -,2 "
echo " complex example: \"-,2 | tail -c 4\" or \"-,2 | grep -o ...$\""
echo "--------------------------------------------------------------------------------------------------------------------------"
echo ""
echo ""
echo ""
exit 1
else
DELIM=$1
for i in *
do
DELIMITER=`echo $DELIM | cut -d , -f1`
FIELD=`echo $DELIM | cut -d , -f2- | cut -d "|" -f1`
CCOUNT=`echo $DELIM | cut -d , -f2- | cut -d "|" -f2-`
if echo $DELIM | grep -q "|"
then
echo $i | cut -d ${DELIMITER} -f${FIELD} | ${CCOUNT}
else
echo $i | cut -d ${DELIMITER} -f${FIELD}
fi
done
fi