文档章节

1: Setting Variables (Working with programs)

Betty__
 Betty__
发布于 2016/09/14 00:35
字数 326
阅读 1
收藏 0

In these shell tutorials, we've been interacting with a computer through the command line. In order to interact with it, we type commands in, those commands are executed, and we're shown the results. That interaction is happening within a shell called bash. A shell is a way to access and control a computer. Command line shells have a text interface for typing commands and seeing results, versus graphical shells which allow you to click on icons with a mouse. There are many unix shells, but Bash is one of the most popular. Bash is the default shell on most Linux and OSX computers.

Bash is essentially a program that lets us run other programs. To do this, Bash implements a command language. This language specifies how we can type and structure commands that will be executed. A command language is a special kind of programming language through which we can control applications and the system. Just like other programming languages, like Python, we can create scripts, set variables, and more. Because it is a language, bash is far more powerful than a graphical shell.

We can set variables by assigning to them. Variables consist entirely of uppercase characters, numbers, and underscores. You can assign any datatype to a variable. Here are some examples:

 

OS=linux

OPERATING_SYSTEM="linux"

Both of the above variables OS andOPERATING_SYSTEM will actually be assigned the same value. Quotes are optional when using strings in bash, unless there's a space in the string -- bash is sensitive to spaces, and strings with spaces won't work properly if they aren't surrounded with quotes.

This assignment won't work:

 

ANIMAL=Shark with a laser beam on its head

But this will:

 

ANIMAL="Shark with a laser beam on its head"

It's also important not to add in stray spaces. This won't work:

 

ANIMAL = "Shark with a laser beam on its

    head"

Instructions

  • Create a variable FOOD containing the value Shrimp gumbo

本文转载自:dataquest

Betty__
粉丝 8
博文 360
码字总数 46678
作品 0
武汉
私信 提问
Git 2.6.2 发布,bug 修复版本

Git 2.6.2 发布,此版本相比 2.6.1,改进如下: ------------------ * There were some classes of errors that "git fsck" diagnosed to its standard error that did not cause it to exit......

淡漠悠然
2015/10/18
1K
0
What SAFe 4.5 Can do for You: Getting the Most out of SAFe 4.5

The release of SAFe® 4.5 couldn't have come at a better time. I've spent most of my career in startups and Lean startups, and UX has truly become my passion. Fortunately, 4.5 ......

Steve Elliott
2017/12/14
0
0
ubuntu从头开始搭建hadoop伪分布式环境

13年学习过一段时间的hadoop,但是工作中用到的地方比较少,有些生疏,加上现在hadoop版本也已经比较新了,所以空闲时间想继续学习一下,找到这篇文章,从头开始搭建一个hadoop环境,转过来备...

ToSun
2015/09/20
258
0
Java Object Oriented Programming concepts

Introduction This tutorial will help you to understand about Java OOP’S concepts with examples. Let’s discuss about what are the features of Object Oriented Programming. Writi......

Jerikc
2014/08/18
131
0
Linear and Quadratic Programming Solver ( Arithmetic and Algebra) CGAL 4.13 -User Manual

1 Which Programs can be Solved? This package lets you solve convex quadratic programs of the general form in n real variables x=(x0,…,xn−1). Here, A is an m×n matrix (the con......

小船1968
2018/12/29
0
0

没有更多内容

加载失败,请刷新页面

加载更多

XXL-JOB使用命令行的方式启动python时,日志过多导致阻塞的解决方式

一、Runtime.getRuntime().exec()的阻塞问题 这个问题也不能算是XXL-JOB的问题,而是Java的Runtime.getRuntime().exec()造成的,BufferedReader的缓冲区大小有限,当不能及时从缓冲区中把输出...

codeobj
2分钟前
0
0
java后端获取字符串标签里面的具体值

1、如下:怎么获取value值,使用Jsoup解决 <select id='department' name='department' class='select' tabindex='6' onchange='changeDept()'><option value=''>院系</optio......

木九天
9分钟前
2
0
Xamarin图表开发基础教程(10)OxyPlot框架支持的图表类型

Xamarin图表开发基础教程(10)OxyPlot框架支持的图表类型 OxyPlot组件支持26种图表,这些图表按照功能和样式可以分为4大类,分别为线型图表、条型图表、金融图表和其它图表。 线型图表 OxyP...

大学霸
12分钟前
2
0
移动端input“输入框”常见问题及解决方法

移动端input“输入框”常见问题及解决方法 1. ios中,输入框获得焦点时,页面输入框被遮盖,定位的元素位置错乱: 当页input存在于吸顶或者吸底元素中时,用户点击输入框,输入法弹出后,fie...

tyou
14分钟前
2
0
初探Android线程池

前言 最近在看OkHttp的源码,看的时候发现有关线程池的运用,自己就仔细想了一下,这个块知识好像不是很牢固。没办法,再研究一下有关线程池的相关知识吧。学习就是一个查漏补缺的过程,最终...

二营长的意大利炮手
21分钟前
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部