环境变量和Bash内置命令

Command Line Editing

Ctrl+a#Move to the start of the line.(光标移到最前面)
Ctrl+e#Move to the end of the line.(光标移到最后面)
Ctrl+l#Clear the screen, reprinting the current line at the top.(不等同clear命令.会在顶部重新打印当前行,当前行还有内容时,还会显示)
#####demo
[root@kafka100 temp]# ls
heap.c
[root@kafka100 temp]# pwd
/root/workspace/cpp/temp
[root@kafka100 temp]# fdsfg
#####此时按下Ctrl+l,将变为下面,可以看到当前行的内容还在
[root@kafka100 temp]# fdsfg

环境变量

[root@kafka100 temp]# /root/workspace/cpp/temp/heap
Current heap end address: 0x15c8000
[root@kafka100 temp]# $(pwd)/heap
Current heap end address: 0x659000
[root@kafka100 temp]# ./heap
Current heap end address: 0x1960000
[root@kafka100 temp]# heap
bash: heap: command not found
# 原因:当前目录并不在PATH环境变量里
# 当可执行文件heap处于PATH环境变量的路径里时,执行的时候,就可以省去./了。
shell variable只有当前shell进程可以使用,当前shell的子进程访问不到

#使当前shell进程的子进程也可以使用
export TEST="test"
export [-fn] [-p] [name[=value]]
#使shell variable可以被当前shell的子进程使用
Mark each name to be passed to child processes in the environment.
If the -f option is supplied, the names refer to shell functions;otherwise the names refer to shell variables.
The -n option causes the export property to be removed from each name.
#让每个shell及其子进程,都能使用该环境变量,将export variable_name=value命令写到Bash的Startup files中

#If no options or arguments are supplied,set displays the names and values of all shell variables and functions.
set
#env和printenv的输出一样
printenv#列出所有的环境变量(If no VARIABLE is specified, prints the value of every environment variable.)
printenv JAVA_HOME KAFKA_HOME#Print the values of the specified environment VARIABLE(s).
env#Output the current environment.

Bash Variables

_:
At shell startup, set to the absolute pathname used to invoke the shell or shell script being executed as passed in the
environment or argument list.
Subsequently, expands to the last argument to the previous command, after expansion.
Also set to the full pathname used to invoke each command executed and placed in the environment exported to that command.
When checking mail, this parameter holds the name of the mail file currently being checked.

BASH_VERSION:Expands to a string describing the version of this instance of bash.
BASH_VERSINFO:A readonly array variable whose members hold version information for this instance of bash.
BASH_VERSINFO[0]#The major version number(the release).
BASH_VERSINFO[1]#The minor version number(the version).
BASH_VERSINFO[2]#The patch level.
BASH_VERSINFO[3]#The build version.
BASH_VERSINFO[4]#The release status(e.g., beta1).
BASH_VERSINFO[5]#The value of MACHTYPE.

HOSTNAME:the name of the current host.
HOSTTYPE:uniquely describes the type of machine on which bash is executing.
MACHTYPE:fully describes the system type on which bash is executing,in the standard GNU cpu-company-system format.

#每次打印提示符之前执行(bash5.1版本中可以是一个数组变量,此时每个元素包含的命令都会执行)
#Bash examines the value of the array variable PROMPT_COMMAND just before printing each primary prompt.
PROMPT_COMMAND:If set, the value is executed as a command prior to issuing each primary prompt.
#读取命令后,执行命令前(bash4.4版本才有的)
PS0:Expanded and displayed by interactive shells after reading a complete command but before executing it.
#提示符(就是每次输命令前面的[root@kafka100 cpp]#)
PS1:The primary prompt string.

BASHOPTS:A colon-separated list of enabled shell options.The options appearing in BASHOPTS are those reported as on by shopt.

Bash Builtin Commands

#Enable and disable builtin shell commands.
#Disabling a builtin allows a disk command which has the same name as a shell builtin to be executed without
#specifying a full pathname, even though the shell normally searches for builtins before disk commands.
#If -n is used, the names become disabled.Otherwise names are enabled.
#If the -p option is supplied, or no name arguments appear, a list of shell builtins is printed.
#The -a option means to list each builtin with an indication of whether or not it is enabled.
enable
enable -n test#禁用test内置命令(use the test binary found via $PATH instead of the shell builtin version)

#For each name, indicate how it would be interpreted if used as a command name.
#If the -t option is used, type prints a single word which is one of ‘alias’, ‘function’, ‘builtin’, ‘file’ or ‘keyword’,
#if name is an alias, shell function, shell builtin, disk file, or shell reserved word, respectively.
#If the -a option is used, type returns all of the places that contain an executable named file.
type [-afptP] [name …]
type -t cat;type -t echo
type -a echo;type -a type;type -a ls;type -a for

whereis#locate the binary, source, and manual page files for a command
whereis echo#列出echo的二进制文件路径,源码文件路径,man手册文件路径

#Toggle the values of settings controlling optional shell behavior.
#With no options,or with the -p option,a list of all settable options is displayed,with an indication of whether
#or not each is set.
shopt

#Display current Readline key and function bindings, bind a key sequence to a Readline function or macro,
#or set a Readline variable.
bind -P >bind_output

https://wiki.calculate-linux.org/bash_shortcuts
https://www.gnu.org/software/bash/manual/bash.html
https://man7.org/linux/man-pages/man1/printenv.1.html
https://www.gnu.org/software/coreutils/manual/html_node/printenv-invocation.html
https://tiswww.case.edu/php/chet/bash/CHANGES
https://unix.stackexchange.com/questions/584003/what-does-the-export-command-do-to-a-variable
https://stackoverflow.com/questions/1158091/defining-a-variable-with-or-without-export
https://www.gnu.org/software/coreutils/manual/html_node/env-invocation.html#env-invocation
https://help.ubuntu.com/community/EnvironmentVariables
https://superuser.com/questions/881897/what-are-the-differences-between-sh-file-sh-and-source-file-sh

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.kler.cn/a/273417.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

android 顺滑滑动嵌套布局

1. 背景 最近项目中用到了上面的布局,于是使用了scrollviewrecycleview,为了自适应高度,重写了recycleview,实现了高度自适应: public class CustomRecyclerView extends RecyclerView {public CustomRecyclerView(Non…

Mac玩《幻兽帕鲁》为什么打不开D3DMetal?d3d错误怎么办 d3dxl error

我之前发了一篇讲Mac电脑玩Steam热门新游《幻兽帕鲁》的文章(没看过的点这里),后来也看到很多朋友去尝试了,遇到了一些问题,无法进入《幻兽帕鲁》游戏,或者是玩的时候卡顿以及出现黑屏,通过我的…

基于YOLOv8深度学习的橙子病害智能诊断与防治系统【python源码+Pyqt5界面+数据集+训练代码】深度学习实战、目标分类

《博主简介》 小伙伴们好,我是阿旭。专注于人工智能、AIGC、python、计算机视觉相关分享研究。 ✌更多学习资源,可关注公-仲-hao:【阿旭算法与机器学习】,共同学习交流~ 👍感谢小伙伴们点赞、关注! 《------往期经典推…

mac清除dns缓存指令 mac清除缓存怎么清理

你是否曾经被要求清理dns缓存并刷新?清理dns缓存一般是由于修改了主机文件,或者想排除一些网络上的故障。在Mac上清除dns缓存需要使用命令行来实现。在本文中,软妹子将向大家介绍mac清除dns缓存指令,并展示mac清除缓存怎么清理。 …

【vscode】vscode重命名变量后多了很多空白行

这种情况,一般出现在重新安装 vscode 后出现。 原因大概率是语言服务器没设置好或设置对。 以 Python 为例,到设置里搜索 "python.languageServer",将 Python 的语言服务器设置为 Pylance 即可。

计算地球圆盘负荷产生的位移

1.研究背景 计算受表面载荷影响的弹性体变形问题有着悠久的历史,涉及到许多著名的数学家和物理学家(Boussinesq 1885;Lamb 1901;Love 1911,1929;Shida 1912;Terazawa 1916;Munk &…

Ubuntu 搭建gitlab服务器,及使用repo管理

一、GitLab安装与配置 GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。 1、安装Ubuntu系统(这个教程很多,就不展开了)。 2、安装gitlab社区版本,有需…

利用textarea和white-space实现最简单的文章编辑器 支持缩进和换行

当你遇到一个非常基础的文章发布和展示的需求,只需要保留换行和空格缩进,你是否会犹豫要使用富文本编辑器?实际上这个用原生的标签两步就能搞定! 1.直接用textarea当编辑器 textarea本身就可以保存空格和换行符,示例如…

vue使用element-ui 实现自定义分页

可以通过插槽实现自定义的分页。在layout里面进行配置。 全部代码 export default { name:Cuspage, props:{total:Number, }, data(){return {currentPage:1,pageSize:10,} } methods: {setslot (h) {return(<div class"cusPage"›<span on-click{this.toBe…

TT-100K数据集,YOLO格式

TT-100K数据集YOLO格式&#xff0c;分为train、val和test&#xff0c;其中train中共有6793张图片&#xff0c;val中共有1949张图片&#xff0c;test中共有996张图片。数据集只保留包含图片数超过100的类别。共计46类。

汽车电子零部件(8):T_Box

前言: 网联汽车(Connected Vehicles ,CV)是一个广泛的概念,四个主要的CV线程已发展起来:互联、自主、共享和电动。这些应用于包括CV在内的垂直领域:汽车、通信、互联网和共享手机服务。中国汽车工程师学会(SAEC)提倡将车载ADAS(高级驾驶员辅助系统)与通信技术相结合…

vsto excel 插件注册表属性值含义

在 VSTO (Visual Studio Tools for Office) 中&#xff0c;LoadBehavior 是用于指定 Office 插件加载行为的一个属性。具体含义如下&#xff1a; - LoadBehavior 0&#xff1a;此值表示插件已被禁用&#xff0c;将不会加载。 - LoadBehavior 1&#xff1a;此值表示插件将在 O…

linux学习之Socket

目录 编写socket-udp 第一步&#xff0c;编写套接字 第二步&#xff0c;绑定端口号 第三步&#xff0c;启动服务器&#xff0c;读取数据 第四步&#xff0c;接收消息并发回信息给对方 编写socket-Tcp 第一步&#xff0c;编写套接字 第二步&#xff0c;绑定端口号 第三步…

多ip多进程代理的实现方法

目录 写在前面 一、背景 二、实现方法 1. 使用多线程处理代理请求 2. 使用多进程处理代理请求 3. 实现多IP代理 三、总结 写在前面 实现多IP多进程代理需要使用Python的多线程和多进程模块。本文将介绍如何使用这些模块来实现多IP多进程代理&#xff0c;并提供相关的代…

Github 2024-03-18开源项目日报Top10

根据Github Trendings的统计,今日(2024-03-18统计)共有10个项目上榜。根据开发语言中项目的数量,汇总情况如下: 开发语言项目数量Python项目7TypeScript项目3非开发语言项目1Solidity项目1《Hello 算法》:动画图解、一键运行的数据结构与算法教程 创建周期:476 天协议类型…

动态规划(蓝桥杯 C++ 题目 代码 注解)

目录 介绍&#xff1a; 题目一&#xff08;数字三角形&#xff09;&#xff1a; 题目二&#xff08;跳跃&#xff09;&#xff1a; 题目三&#xff08;背包问题类型&#xff09;&#xff1a; 题目四&#xff08;蓝肽子序列&#xff09;&#xff1a; 题目五&#xff08;合唱…

[TJOI2010] 阅读理解 **STL**Tire树**

[TJOI2010] 阅读理解 题目链接&#xff1a; https://www.luogu.com.cn/problem/P3879 题目描述 思路1 &#xff08;STL大法&#xff09; 对每个单词&#xff0c;用map来映射存储它所在的短文编号 用set的好处&#xff1a; -------1. 存储直接自动排序&#xff0c;操作简单&…

003——移植鸿蒙

目录 一、顶层Make分析 二、添加一个新的单板 2.1 Kconfig 2.2 Makefile 2.2.1 顶层Makefile 2.2.2 platform下的Makefile 2.2.3 platform下的bsp.mk文件 2.3 编译与调试 2.4 解决链接错误 三、内核启动流程的学习 3.1 韦东山老师总结的启动四步 3.2 启动文件分析…

Coursera上Golang专项课程3:Concurrency in Go 学习笔记(完结)

Concurrency in Go 本文是 Concurrency in Go 这门课的学习笔记&#xff0c;如有侵权&#xff0c;请联系删除。 文章目录 Concurrency in GoMODULE 1: Why Use Concurrency?Learning Objectives M1.1.1 - Parallel ExecutionM1.1.2 - Von Neumann BottleneckM1.1.3 - Power W…

LLM 构建Data Multi-Agents 赋能数据分析平台的实践之②:数据治理之一

概述 数据治理不仅是产业数字化转型的基石&#xff0c;更是推动产业向更高层次、更精细化、更智能的方向发展的重要引擎。通过科学有效的数据治理实践&#xff0c;产业能够在数字化进程中实现数据驱动的决策与行动&#xff0c;最终达到转型升级的战略目标。 一、数据治理在产业…
最新文章