-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.sh
executable file
·49 lines (30 loc) · 996 Bytes
/
example.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
45
46
47
48
49
#!/bin/sh
set -eu
. ./path.sh
# path_dirname var pathname
path_dirname ret "/var/tmp/file.txt"
echo "$ret" # => /var/tmp
# path_basename varname pathname [suffix]
path_basename ret "/var/tmp/file.txt"
echo "$ret" # => file.txt
# path_extname varname pathname [suffix]
path_extname ret "/var/tmp/file.txt"
echo "$ret" # => .txt
# path_rootname varname pathname [suffix]
path_rootname ret "/var/tmp/file.txt"
echo "$ret" # => /var/tmp/file
# path_normalize varname pathname [basedir]
path_normalize ret "/var///tmp/.././file.txt"
echo "$ret" # => /var/file.txt
# path_relative varname pathname [basedir]
path_relative ret "/var/tmp/file.txt" /var/
echo "$ret" # => ./tmp/file.txt
# suffix examples
path_extname ret "/var/tmp/file.tar.gz" .gz
echo "$ret" # => .gz
path_extname ret "/var/tmp/file.tar.gz" .tar.gz
echo "$ret" # => .tar.gz
path_extname ret "/var/tmp/file.tar.gz" ".*.*"
echo "$ret" # => .tar.gz
path_extname ret "/var/tmp/file.tar.gz" ".**"
echo "$ret" # => .tar.gz