Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use logical commands in Linux system

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use logical commands in Linux system". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to use Linux system logic commands".

1. Determine the result of a command using test, which returns 0, or an integer. Return 0 for true and return integer for error code

two。 Get the return result of the previous command using $?

3. For example

There is a folder like / home/www on my server, so the return result of the command ls / home/www is 0

Namely echo $? The return value is 0

There is no folder such as / home/kkk on my server, so the return result of the command ls / home/kkk is the error code after the command is executed.

Namely echo $? The return result is 2. This 2 indicates that the file or folder does not exist.

4. Commonly used file test characters

-e indicates whether this file name exists

-f indicates whether the file name is a file

-d indicates whether the file name is a folder

-r indicates whether the file name is readable

-w indicates whether this file is writable

-x indicates whether this file is executable or not

-S indicates whether this file asks socket

4.1 on my server / home/www is a folder

So the result of test-e / home/www is 0, which is true, and this file name exists

So the result of test-f / home/www is not 0, that is, false, and the file name is not a file

So the result of test-d / home/www is 0, which is true, and this file is called folder

4.2 the file name / home/kkk does not exist on my server

So the result of test-e / home/kkk is not 0, that is, false, this file name does not exist

So the result of test-d / home/kkk is not 0, that is, false, this file name does not ask about the folder.

At this point, I believe you have a deeper understanding of "the use of Linux system logic commands". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report