当前位置: 首页 > news >正文

【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 --versionThis 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 WallPerl 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/perlprint "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/python3print("hello world!")

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

shell

#!/usr/bin/bashecho "hello world!"

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

tcl

#!/usr/bin/tclshputs "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

点击“运行”:

执行效果:

http://www.lryc.cn/news/151322.html

相关文章:

  • 解决npm install报错: No module named gyp
  • Leetcode 面试题 17.01 不用加号的加法
  • 一个 MySQL 数据库死锁的案例和解决方案
  • AMBEO 双声道空间音频现已迈进直播制作领域
  • 在VSCode上画UML的三个插件
  • Springboot - 1.什么是springboot
  • 学习微信小程序 Westore
  • CentOS上使用Docker安装和部署kkFileView
  • Level-based Foraging 多智能体游戏仿真环境
  • LeetCode-53-最大子数组和-贪心算法
  • 解决gitee仓库中 .git 文件夹过大的问题
  • uniapp 开发小程序,封装一个方法,让图片使用线上地址
  • Android 12 源码分析 —— 应用层 三(SystemUIFactory及其Dependency解析)
  • 考前冲刺上岸浙工商MBA的备考经验分享
  • XmlDocument.SelectNodes 不起作用
  • 部署单点elasticsearch
  • ElementUI浅尝辄止16:Tag 标签
  • Java虚拟机(JVM)框架
  • 配置Publisher 的编译规则
  • 【SpringBoot】接口实现:SpringBoot实现博客系统的文章列表页接口代码
  • 如何使用SQL系列 之 如何在SQL中插入数据
  • 【LeetCode题目详解】1281题 整数的各位积和之差 面试题 01.01. 判定字符是否唯一 python题解(作业一二)
  • 1.12 进程注入ShellCode套接字
  • MySQL 日志系统
  • LeetCode刷题---Two Sum(一)
  • 算法通关村第十七关——插入区间
  • Jenkins java8安装版本安装
  • 线上问诊:数仓开发(二)
  • Ansible自动化运维工具(三)
  • ChatGPT在创新和创业中的应用如何?