In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces shell how to find symbolic links and point to the target, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
1. Symbolic links can be seen as pointers to other files. It is functionally similar to aliases in Mac OS or shortcuts in windows, keeping in mind that it is similar, not just.
2. Deleting the symbolic link will not affect the original file.
Create a symbolic link:
$ln-s target symbolic_link_name
For example:
$ln-s / var/www/ ~ / web
This command creates a symbolic link called web in the home directory of the logged in user. This link points to / var/www/. This information can be seen in the following command output:
The code is as follows:
$ls web
Lrwxrwxrwx 1 slynux slynux 8 2013-02-07 19:16 web-> / var/www
The web-> / var/www in the message above indicates that web points to / var/www.
For each symbolic link, the permission tag section starts with the letter "l", indicating that this is a symbolic link.
Therefore, to print the symbolic links in the current directory, you can use the following command:
$ls-l | grep "^ l" | awk'{print $8}'
Grep filters the output of ls-l to show only those lines that start with l. ^ is the beginning of the string. Awk is used to print out the eighth column, that is, the file name section.
Another way is to print symbolic links using find, as follows:
$find. -type l-print
In the above command, you specify "l" as the type parameter of the find command, telling find to search only symbolic link files.
The-print option prints the symbolic link list to standard output (stdout). And "." Indicates that the search starts from the current directory.
Using the following command, you can print the symbolic link pointing to the target:
$ls-l web | awk'{print $10}'
/ var/www
Each line output by the ls-l command corresponds to the details of a file.
Ls-l web lists all the details of the symbolic link file web. The 10th column of the output contains the target that the file points to (if this is a symbolic link).
Therefore, in order to find the target associated with the symbolic link, we can use awk to print out the 10th column of the detailed list of files (the output of ls-l).
In addition, we can also use the readlink command to accomplish the same task. In some cases, this is the highest priority usage, and its usage is as follows:
$readlink web
/ var/www
Thank you for reading this article carefully. I hope the article "how to find symbolic links and their goals in shell" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and follow the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.