/
file_path_bash.sh
90 lines (87 loc) · 2.03 KB
/
file_path_bash.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
pwd
# /Users/mbp/Documents/my-project/python-snippets/notebook
python3 data/src/file_path.py
# getcwd: /Users/mbp/Documents/my-project/python-snippets/notebook
# __file__: data/src/file_path.py
# basename: file_path.py
# dirname: data/src
# abspath: /Users/mbp/Documents/my-project/python-snippets/notebook/data/src/file_path.py
# abs dirname: /Users/mbp/Documents/my-project/python-snippets/notebook/data/src
#
# [set target path 1]
# target_path_1: data/src/test.txt
# read target file:
# line 1
# line 2
# line 3
#
# [set target path 2]
# target_path_2: data/src/../dst/test_new.json
# read target file:
# {
# "A": 100,
# "B": "abc",
# "C": "あいうえお"
# }
#
# [change directory]
# getcwd: /Users/mbp/Documents/my-project/python-snippets/notebook/data/src
#
# [set target path 1 (after chdir)]
# target_path_1: test.txt
# read target file:
# line 1
# line 2
# line 3
#
# [set target path 2 (after chdir)]
# target_path_2: ../dst/test_new.json
# read target file:
# {
# "A": 100,
# "B": "abc",
# "C": "あいうえお"
# }
cd data/src
python3 file_path.py
# getcwd: /Users/mbp/Documents/my-project/python-snippets/notebook/data/src
# __file__: file_path.py
# basename: file_path.py
# dirname:
# abspath: /Users/mbp/Documents/my-project/python-snippets/notebook/data/src/file_path.py
# abs dirname: /Users/mbp/Documents/my-project/python-snippets/notebook/data/src
#
# [set target path 1]
# target_path_1: test.txt
# read target file:
# line 1
# line 2
# line 3
#
# [set target path 2]
# target_path_2: ../dst/test_new.json
# read target file:
# {
# "A": 100,
# "B": "abc",
# "C": "あいうえお"
# }
#
# [change directory]
# getcwd: /Users/mbp/Documents/my-project/python-snippets/notebook/data/src
#
# [set target path 1 (after chdir)]
# target_path_1: test.txt
# read target file:
# line 1
# line 2
# line 3
#
# [set target path 2 (after chdir)]
# target_path_2: ../dst/test_new.json
# read target file:
# {
# "A": 100,
# "B": "abc",
# "C": "あいうえお"
# }