readlink -f \"\$0\"
时间: 2023-09-15 12:23:32 浏览: 127
`readlink -f "\$0"` is a shell command used to retrieve the absolute path of the current script. It resolves any symbolic links and returns the full path to the script.
相关问题
readlink -f ${0}
As an AI language model, I do not have access to the file system of the machine I am running on, so I cannot execute the `readlink -f ${0}` command or any other command that requires access to the file system. However, in general, the `readlink -f ${0}` command is used to obtain the absolute path of the script or executable file that is being executed. The `${0}` parameter refers to the name of the current script or executable file, and `readlink -f` resolves any symbolic links and returns the absolute path of the file.
$ readlink -f $(which javac) | sed "s:/bin/javac::"找不到
如果 `readlink -f $(which javac) | sed "s:/bin/javac::"` 命令找不到 JDK 安装路径,您可以尝试以下方法:
1. 如果您已经安装了 JDK,请确保 JAVA_HOME 环境变量已经正确设置。您可以在终端中输入 `echo $JAVA_HOME` 命令来检查环境变量是否已经设置。如果命令没有输出,则说明 JAVA_HOME 没有设置或者设置不正确。
2. 如果您没有安装 JDK,则需要先安装 JDK。您可以在终端中运行以下命令来安装 OpenJDK:
```bash
$ sudo apt update
$ sudo apt install openjdk-8-jdk
```
如果您使用的是其他 Linux 发行版,请根据其官方文档来安装 OpenJDK。
3. 安装完成后,您可以使用以下命令来查找 JDK 的安装路径:
```bash
$ readlink -f $(which java) | sed "s:/bin/java::"
```
如果您成功找到了 JDK 的安装路径,则将该路径添加到 JAVA_HOME 环境变量中。您可以使用以下命令来编辑 ~/.bashrc 文件并添加 JAVA_HOME 环境变量:
```bash
$ echo "export JAVA_HOME=<JDK 安装路径>" >> ~/.bashrc
$ source ~/.bashrc
```
将 `<JDK 安装路径>` 替换为您找到的 JDK 安装路径。
4. 现在,您可以再次使用 `readlink -f $(which javac) | sed "s:/bin/javac::"` 命令来查找 JDK 安装路径。如果命令成功输出 JDK 的安装路径,则您已经成功设置了 JAVA_HOME 环境变量。
阅读全文
相关推荐
















