linux - Ubuntu:如何在 shell 中输入目录

标签 linux shell ubuntu

在我的桌面上我创建了一个名为“Files”的文件夹,我想知道如何通过 shell 脚本访问该文件夹

最佳答案

在 Linux 文件系统中使用 bash 时,您可以通过多种方式导航到主目录:

到达主目录后,一切都很容易,包括到达桌面。

The ~ or $HOME reference: In Linux based systems the keyword ~ or $HOME refers to the home directory of the computer.

例如,假设您当前位于 /bin,如果您知道您的用户名,则导航到主页:

$ cd /home/yourusername
#The directory is now switched to :
$ pwd #This command stands for print working directory
'/home/yourusername'

现在您可以通过以下方式进行选择: (再次假设您位于 /bin 中)

$ cd $HOME
$ pwd
'/home/yourusername'
#Alternatively
$ cd /bin
$ cd ~
$ pwd
'/home/yourusername'

这些快捷方式让您无需编写太多内容即可回家,甚至值得推荐。

现在,对于您的问题,您可以通过以下方式轻松导航到您的文件夹:

cd ~/Desktop/Files/

关于linux - Ubuntu:如何在 shell 中输入目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48364266/

相关文章:

linux - 在 BASH 中的选定文本中搜索字符串/模式

shell - WAR文件部署中的Grails Shell

Linux平台: Enlarge video screen size N times

linux sed,如何删除剩下的字?

R h2o getHelpFile : package 'XYZ' exists but was not installed under R >= ver. num 所以无法访问帮助

c++ - 用GTK制作逻辑门模拟器,放置区如何制作?

java - 未找到 json-simple.jar

linux - X11/XCB/Xlib : Copy root window to pixmap

pdf - 如何在 postscript 文件上制作程序覆盖文本?

css - Ubuntu CLI 中的红色文件名 (Vagrant)