zoukankan      html  css  js  c++  java
  • Linux命令——mesg

    参考:图解Linux命令之--mesg命令

    Linux mesg命令

    前言

    在看一个脚本~/.profile 的时候发现了mesg命令以及一个奇怪用法

    ~/.profile 

    # ~/.profile: executed by Bourne-compatible login shells.
    
    if [ "$BASH" ]; then
      if [ -f ~/.bashrc ]; then
        . ~/.bashrc
      fi
    fi
    
    mesg n || true
    View Code

    meag命令

    语法

    mesg [ny]

    功能

    用来设置当前终端的写权限,即是否让其他用户向本终端发信息

    参数

    n 不允许其他用户将信息直接显示在你的屏幕上。

    y 允许其他用户将信息直接显示在你的屏幕上。

    演示

     1) 如果mesg n设置为n的话,用write,talk命令时,会显示write permission turned off提示

     2) 两个终端通过write命令发送讯息的过程

    mesg n || true中 || true啥意思?

    参考:What does the || true do in the mesg command do?

    It forces the whole expression to exit with a success status: The operator "||" means the command to the right is only executed if the command beforehand exited with a "failure status" (exit code != 0). The "true" command does nothing but exit with exit code 0 which means "success".

    简单翻一下

    mesg n || true可以保证这句话退出状态是success。只有当||前面那句话执行失败,即mesg n 执行失败时,||后面才会执行。相当于||前面那句话退出码!0,现在变成0.

     

  • 相关阅读:
    HDU2519(组合数计算)
    CodeForces
    UVA 10976(暴力)
    UVA 11059(暴力)
    UVA725
    配置三层交换机DHCP
    通过三层交换机不同vlan之间通信
    AGC006C & CF1110E
    多项式全家桶
    一些模板(持续更新中)
  • 原文地址:https://www.cnblogs.com/kelamoyujuzhen/p/9801285.html
Copyright © 2011-2022 走看看