File tree Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ source <(curl -fsSL https://raw.githubusercontent.com/oldratlee/useful-scripts/m
3636 彩色` cat ` 出文件行,方便人眼区分不同的行。
37371 . [ a2l] ( docs/shell.md#beer-a2l )
3838 按行彩色输出参数,方便人眼查看。
39+ 1 . [ ap and rp] ( docs/shell.md#beer-ap-and-rp )
40+ 批量转换文件路径为绝对路径/相对路径,会自动跟踪链接并规范化路径。
39411 . [ xpl and xpf] ( docs/shell.md#beer-xpl-and-xpf )
4042 在命令行中快速完成 在文件浏览器中 打开/选中 指定的文件或文件夹的操作。
41431 . [ tcp-connection-state-counter.sh] ( docs/shell.md#beer-tcp-connection-state-countersh )
Original file line number Diff line number Diff line change 11#! /bin/bash
22# @Function
3- # convert to absolute path .
3+ # convert to Absolute Path .
44#
55# @Usage
6+ # # print Absolute Path of current directory.
67# $ ./ap
8+ # # print Absolute Path of arguments.
79# $ ./ap a.txt ../dir1/b.txt
810#
911# @author Jerry Lee
Original file line number Diff line number Diff line change @@ -95,6 +95,37 @@ test-cases/self-installer.sh
9595
9696注:上面显示中,没有彩色,在控制台上运行可以看出彩色效果。
9797
98+ :beer : [ ap] ( ../ap ) and [ rp] ( ../rp )
99+ ----------------------
100+
101+ 批量转换文件路径为绝对路径/相对路径,会自动跟踪链接并规范化路径。
102+
103+ 命令名` ap ` 意思是` Absolute Path ` ,` rp ` 是` Relative Path ` 。
104+
105+ ### 示例
106+
107+ ``` bash
108+ # ap缺省打印当前路径的绝对路径
109+ $ ap
110+ /home/admin/useful-scripts/test
111+ $ ap ..
112+ /home/admin/useful-scripts
113+ # 支持多个参数
114+ $ ap .. ../.. /etc /etc/../etc
115+ /home/admin/useful-scripts
116+ /home/admin
117+ /etc
118+ /etc
119+
120+ # rp当一个参数时,打印相对于当前路径的相对路径
121+ $ rp /home
122+ ../..
123+ # 多于一个参数时,打印相对于最后一个参数的相对路径
124+ $ rp /home /etc/../etc /home/admin
125+ ..
126+ ../../etc
127+ ```
128+
98129:beer : [ xpl] ( ../xpl ) and [ xpf] ( ../xpf )
99130----------------------
100131
Original file line number Diff line number Diff line change 11#! /bin/bash
2+ # @Function
3+ # convert to Relative Path.
4+ #
5+ # @Usage
6+ # # if 1 argument, print relative path to current dir.
7+ # $ ./rp /etc/apache2/httpd.conf
8+ # # if more than 1 argument, print relative path to last argument.
9+ # $ ./rp a.txt ../b.txt /etc/passwd /etc/apache2
10+ #
11+ # @author Jerry Lee
12+
213[ $# -eq 0 ] && {
314 echo " ERROR: NO argument!"
415 exit 1
You can’t perform that action at this time.
0 commit comments