linux导出日志命令

In this guide, we will look at the export command in Linux. Export is a built-in command of the Bash shell. It is used to mark variables and functions to be passed to child processes. Basically, a variable will be included in child process environments without affecting other environments. To get a clearer picture of what we are talking about, let’s dive in and have a look at the export command examples.

在本指南中,我们将研究Linux中的export命令。 导出是Bash shell的内置命令。 它用于标记要传递给子进程的变量和函数。 基本上,变量将包含在子进程环境中,而不会影响其他环境。 为了更清楚地了解我们在说什么,让我们深入研究一下export命令示例。

在Linux中不带任何参数的导出命令 (Export command in Linux without any arguments)

Without any arguments, the command will generate or display all exported variables. Below is an example of the expected output.

不带任何参数的命令将生成或显示所有导出的变量。 以下是预期输出的示例。

$ export

Sample output

样品输出

查看当前shell上的所有导出变量 (Viewing all exported variables on current shell)

If you wish to view all exported variables on the current shell, use the -p flag as shown in the example

如果希望查看当前shell上的所有导出变量,请使用-p标志,如示例所示

$ export -p

Sample output

样品输出

使用导出功能 (Using export with functions)

Suppose you have a function and you wish to export it, how do you go about it? In this case , the -f flag is used. In this example, we are exporting the function name ().

假设您有一个函数并且希望导出它,该如何处理? 在这种情况下,将使用-f标志。 在此示例中,我们导出函数name ()

First, call the function

首先,调用函数

$ name () { echo "Hello world"; }

Then export it using the -f flag

然后使用-f标志将其导出

$ export -f name

Next, invoke bash shell

接下来,调用bash shell

$ bash

Finally, call the function

最后,调用函数

$ name

Output

输出量

Hello World

You can also assign a value before exporting a function as shown

您还可以在导出函数之前分配一个值,如下所示

$ export name[=value]

For example, you can define a variable before exporting it as shown

例如,您可以在导出变量之前定义一个变量,如下所示

$ student=Divya

In the above example, the variable ‘student’ has been assigned the value ‘Divya’

在上面的示例中,变量“ student”被分配了值“ Divya”

To export the variable run

导出变量运行

$ export students

You can use the printenv command to verify the contents of the variable as shown

您可以使用printenv命令来验证变量的内容,如下所示

$ printenv students

Check the output below of the commands we have just executed

检查下面我们刚刚执行的命令的输出

Output

输出量

The above can be achieved in 2 simple steps by declaring and exporting the variable in one line as shown

可以通过两个简单的步骤就可以实现上述目标,方法是在一行中声明并导出变量,如图所示

$ export student=Divya

To display the variable run

显示变量运行

$ printenv student

Output

输出量

This concludes our tutorial about export command. Go ahead and give it a try and see the magic! Your feedback is most welcome.

到此结束我们有关导出命令的教程。 继续尝试一下,看看魔术! 非常欢迎您提供反馈。

翻译自: https://www.journaldev.com/28251/export-command-linux

linux导出日志命令

linux导出日志命令_Linux中的导出命令相关推荐

  1. linux中top命令_Linux中的top命令指南

    linux中top命令 The atop command is a tool for monitoring system resources in Linux. It displays tons of ...

  2. linux中nohup命令_Linux中的Nohup命令

    linux中nohup命令 When exiting the shell of a Linux System, all running processes are usually terminated ...

  3. linux中sudo命令_Linux中的Sudo命令

    linux中sudo命令 Sudo is one of the most widely used commands by Linux administrators and beginners alik ...

  4. linux wget返回值_Linux中的Wget命令与示例

    GNU Wget是用于从Web下载文件的命令行实用程序.使用Wget,您可以使用HTTP,HTTPS和FTP协议下载文件. Wget提供了许多选项,使您可以下载多个文件,恢复下载,限制带宽,递归下载, ...

  5. 压缩命令_linux中压缩文件命令gzip和tar的压缩选项的简单用法

    linux当中压缩命令有多种,比较常用的有gzip gzip的用法很简单,把要压缩的文件或列表跟在命令gzip的后面就可以了. gzip 要压缩的文件 | 列表 gzip file.tar 压缩打包文 ...

  6. linux mkfs 源码,Linux系统下移植busybox中mkfs.vfat命令

    为了延长磁盘寿命来存储音视频文件,打发在格式化磁盘过程中将簇的大小设置大点.因为存储的音视频文件现对较大,那么将簇大小设置得尽可能大,这样可以增强磁盘读取数据的性能,同时也不会浪费太多空间. 但发现我 ...

  7. 在 Windows 命令行中实现 cp 命令

    第一步,创建一个文本文件,输入如下内容: @echo off copy %* 第二步,将上面的文本文件另存为 cp.bat 保存到 C:\Windows 目录下,然后就可以用了 如果按照本示例的用法, ...

  8. linux mv 保持目录结构_Linux中的mv命令详解

    mv命令是move的缩写,可以用来移动文件或者将文件改名(move (rename) files),是Linux系统下常用的命令,经常用来备份文件或者目录. 1.命令格式: mv [选项] 源文件或目 ...

  9. 解压命令linux tgz,tar 解压_linux中的“tar命令”怎么解压“.tgz”与“.tar.gz”文件?...

    在LINUX下如何将tar压缩文件解压到指定的目录下 一.解压.tar.gz格式到指定的目录下: 命令格式为:tar -zxvf [压缩包文件名.tar.gz] -C  [路径]/ 例如:tar -z ...

最新文章

  1. 要离校了,使用SSM为学校开发后勤报修系统
  2. PHP基本连接数据库
  3. Partition学习笔记
  4. 使用xrandr和cvt命令添加自定义的分辨率模式
  5. fastclick.js移动端WEB开发,click,touch,tap事件浅析
  6. 图片在mysql中的储存_如何在MySQL中直接储存图片
  7. vue中Component错误
  8. win10 安装sqlserver2000
  9. 数学分析教程 第十二章学习感受
  10. getbook netty实战_《Netty实战》Netty In Action中文版 第1章 Netty——异步和事件驱动...
  11. C语言六边形蜂巢数组,CSS 实现蜂巢/六边形图集
  12. Codevs 3100 蜗牛的旅行
  13. 网管服务器系统巡检报告,网络设备巡检报告-20210730125215.docx-原创力文档
  14. 【富文本】2019年上半年英语四、六级成绩查询时间(附不需要验证码的查询网站)
  15. android界面美化
  16. 8.4 向量应用(二)——空间直线
  17. html5/css实现字体上划线
  18. 如何转换DWG文件格式?来试试这两种方法
  19. 【CodingNoBorder - 06】无际软工队 - 会议纪要博客列表
  20. android:使用Gon解析解析json

热门文章

  1. 17.3.10--关于C元的变量类型所占字节问题和类型转化
  2. 同一界面放两个TTIWDBAdvWebGrid的问题(delphi IW TMS)
  3. 用ajax向处理页面传送路径问题解决方法
  4. 一只火鸡带你了解大数据预测(经典)
  5. [转载] python 超高精度除法_Python十进制-除法,舍入,精度
  6. Mysql常用的几种join连接方式
  7. Django-manage.py
  8. MySQL数据库中,将一个字段的值分割成多条数据显示
  9. Django(6)-orm
  10. (5)ES6解构赋值-函数篇