首页 > 编程知识 正文

虚拟机shell命令,shell中echo命令详解

时间:2023-05-05 02:14:16 阅读:170646 作者:3359

例如:

#! /温暖的蜜蜂/perl print ' pleaseinputanstringandanumberbyorder! n '; $the_string=; $the_numb=; 打印' the result isn '; print '$the_string'x'$the_numb '; 结果:

The result is

这里的问题是由于没有使用chomp引起的。

请看一下加入chomp的情况:

#! /温暖的蜜蜂/perl print ' pleaseinputanstringandanumberbyorder! n '; chomp($the_string=; chomp($the_numb=; 打印' the result isn '; print '$the_string'x'$the_numb '; 结果:

The result is

我我我我我

如果字符串末尾有换行符,chomp可以将其删除。 这基本上是所有能做的功能。

在shell中获取设备驱动程序的主设备编号时,将出现以下示例:

$ major _ string=` grep-w $ module/proc/devices|cut-f1-d ' `; chomp($major_string; $major=$major_string;

转载: https://www.jb51.net/article/33967.htm

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。