【ICer的脚本练习】“精通各种语言的hello world!“

系列的目录说明请见:ICer的脚本练习专栏介绍与全流程目录_尼德兰的喵的博客-CSDN博客

前言

这一节呢主要是检查一下Linux和win环境是不是能正常的支持咱们的脚本学习,所以来答应各种语言的hello world!,毕竟打印了就是学会了٩(๑❛ᴗ❛๑)۶顺便从最基础的细节咱们一点一点来。

准备工作

和之前一样,你手里应该已经有linux系统的虚拟机了,那么检查一下环境中的工具支持:

[ICer@IC_EDA /home/ICer]$which perl
/usr/bin/perl
[ICer@IC_EDA /home/ICer]$perl --version

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 44 registered patches, see perl -V for more detail)

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
[ICer@IC_EDA /home/ICer]$which python
/usr/bin/python
[ICer@IC_EDA /home/ICer]$python --version
Python 2.7.5
[ICer@IC_EDA /home/ICer]$which python3
/usr/bin/python3
[ICer@IC_EDA /home/ICer]$python3 --version
Python 3.6.8
[ICer@IC_EDA /home/ICer]$which bash
/usr/bin/bash
[ICer@IC_EDA /home/ICer]$bash --version
GNU bash, 版本 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
许可证 GPLv3+: GNU GPL 许可证版本3或者更高 <http://gnu.org/licenses/gpl.html>

这是自由软件,您可以自由地更改和重新发布。
在法律允许的范围内没有担保.
[ICer@IC_EDA /home/ICer]$which csh
/usr/bin/csh
[ICer@IC_EDA /home/ICer]$csh --version
tcsh 6.18.01 (Astron) 2012-02-14 (x86_64-unknown-linux) options wide,nls,dl,al,kan,sm,rh,color,filec
[ICer@IC_EDA /home/ICer]$which tclsh
/usr/bin/tclsh
[ICer@IC_EDA /usr/local/bin]$make -v
GNU Make 4.2
为 x86_64-pc-linux-gnu 编译
Copyright (C) 1988-2016 Free Software Foundation, Inc.
许可证:GPLv3+:GNU 通用公共许可证第 3 版或更新版本<http://gnu.org/licenses/gpl.html>。
本软件是自由软件:您可以自由修改和重新发布它。
在法律允许的范围内没有其他保证。
[ICer@IC_EDA /usr/local/bin]$which awk
/usr/bin/awk
[ICer@IC_EDA /usr/local/bin]$which sed
/usr/bin/sed

然后再打开正版激活后的excel,点击“文件” - “选项” - “自定义功能区”:

好的,准备工作完成了。

第一次执行

在linux环境下右键打开终端,输入:

[ICer@IC_EDA /home/ICer]$echo 'hello world!'
hello world!

注意这里不要使用双引号,否则会报错(参见Linux -bash: !“: event not found 问题解决),那么这句话怎么转变为脚本呢?

新建一个demo文件,在里面写入:

echo "hello woirld!"

对,在脚本里就可以用双引号了,然后保存后,在终端执行以bash来执行:

[ICer@IC_EDA /home/ICer/gitee_path/ic_script_prj/hello_world]$bash ./demo
hello world!

或者将demo的文件属性改为可执行状态:

chmod a+x demo

然后就可以直接执行了:

[ICer@IC_EDA /home/ICer/gitee_path/ic_script_prj/hello_world]$./demo
hello world!

好的,到目前为止,第一个脚本执行成功了!

精通各种hello world!

perl

新建demo.pl,写入:

print "hello world!\n"

之后在终端键入:

[ICer@IC_EDA /home/ICer/gitee_path/ic_script_prj/hello_world]$perl demo.pl
hello world!

然后在demo.pl的首行写入并改为可执行属性:

#!/usr/bin/perl

print "hello world!\n"

执行脚本:

[ICer@IC_EDA /home/ICer/gitee_path/ic_script_prj/hello_world]$./demo.pl 
hello world!

首行的#!/usr/bin/perl是为这个脚本指定默认的执行语言。

python

#!/usr/bin/python3

print("hello world!")

不要使用python,统一使用python3。

shell

#!/usr/bin/bash

echo "hello world!"

通常来说shell默认值bash版本。

tcl

#!/usr/bin/tclsh

puts "hello world!"

make

新建Makefile,写入:

target:
	@echo "hello world!"

在终端键入make:

[ICer@IC_EDA /home/ICer/gitee_path/ic_script_prj/hello_world]$make
hello world!

awk

直接在终端键入:

[ICer@IC_EDA /home/ICer/gitee_path/ic_script_prj/hello_world]$echo 'hello world!' | awk '{print $0}'
hello world!

然后可以固化在makefile中:

target:
	@echo "hello world!" | awk '{print $0}'

VBA

打开excel,点击“开发工具” - “Visual Basic”,右键插入“模块”:

在模块内“插入” - “过程”:

之后在sub demo中写入:

Public Sub demo()
    Debug.Print "hello, world!"
    MsgBox "hello, world!", 3 + 48 + 256, "Demo"
End Sub

点击“运行”:

执行效果:

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

尼德兰的喵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值