【问题标题】:Get absolute URL path using bash in linux在 linux 中使用 bash 获取绝对 URL 路径
【发布时间】:2018-05-19 22:19:53
【问题描述】:

有一个相对 URL。例如 bstu.by。如何通过 bash 获取绝对 URL 路径?允许使用任何控制台实用程序 linux。

【问题讨论】:

标签: linux bash url console absolute


【解决方案1】:

使用readlink 实用程序

readlink -f bstu.by

这也可用于使用which 解析路径二进制文件,如下所示

readlink -f 'which java'请使用`代替'

【讨论】:

  • 可以使用readlink -f $(which java),基本一样。
【解决方案2】:

使用realpath:

NAME
       realpath - print the resolved path

SYNOPSIS
       realpath [OPTION]... FILE...

DESCRIPTION
       Print the resolved absolute file name; all but the last component must exist

例子:

/etc$ realpath passwd
/etc/passwd

请注意,它还解析符号链接,因此生成的文件名可能不同:

/bin$ realpath awk
/usr/bin/gawk

【讨论】:

    猜你喜欢
    • 2022-06-10
    • 2013-08-25
    • 2012-08-27
    • 2015-11-15
    • 2017-02-22
    • 2016-07-23
    • 2014-02-23
    • 2021-10-18
    • 2015-04-14
    相关资源
    最近更新 更多