bash

How to filter the running nodes

送分小仙女□ 提交于 2021-02-17 07:07:47
问题 I want to filter the running nodes list . I tried below command but its only showing running status.I need to filter with it name..Any help ? [root@techsl]# kubectl get nodes -o jsonpath='{range .items[ ]}{@.metadata.name}:{range @.status. enter code here conditions[ ]}{@.type}={@.status};{end}{end}'| tr ';' "\n" | grep "Ready=True" 回答1: Something like this is easier: kubectl get nodes | grep -v NotReady | awk '{print $1}' | tail -n2 server1 server3 kubectl get nodes NAME STATUS ROLES AGE

云原生系列3 pod核心字段

可紊 提交于 2021-02-17 06:47:09
<br /> <br /> <br />pod是容器化的基础,好比大楼的地基。<br /> Pod跟容器的关系 <br /> <br />类比一下:<br /> <br />POD: 物理机<br />容器: 物理机上的一个进程;<br /> <br />容器只是Pod的一个普通字段。<br /> <br /> Pod的作用范围 <br />跟容器的linux namespace相关的东西一定是Pod级别的,pod。<br /> <br /> <br />比如:<br /> <br />网络: hostAliases : 写入/ect/hosts内容 ; sharePrcessNamespace: 共享PID 空间<br /> <br />存储: vlume<br /> <br />安全: secret<br /> <br />调度: NodeSelector 用户指定pod跟node的对应关系 ; NodeName 标识调度过了,可用来调试pod;<br /> <br /> <br /> <br /> Pod的Container元素 containers和initContainers关系 <br /> <br />initContainers先于containers创建 ; sidecar实现的重要基础;按照定义的顺序来执行;<br /> <br />containers:

bash replace variable name in string with variable value

纵然是瞬间 提交于 2021-02-17 06:37:05
问题 This is kind of a weird one. I have the following string: I have a variable called REDIRECT set to: https://working.${MYDOMAIN}/blah/blah . I need to replace the ${MYDOMAIN} with the actual value of the variable assigned to ${MYDOMAIN}. Not sure if bash or sed is best for this. I tried bash replace but couldn't get it to work, probably related to escaping the characters or something. Any help appreciated! 回答1: You may use this bash substitution: echo "${REDIRECT/\${MYDOMAIN\}/$MYDOMAIN}" or

Dynamic regular expressions in awk

ぃ、小莉子 提交于 2021-02-17 05:46:29
问题 I have text files like 1.txt AA;00000; BB;11111; GG;22222; 2.txt KK;WW;55555;11111; KK;FF;ZZ;11111; KK;RR;YY;11111; I generate this 3.txt output AA;00000; BB;11111;KK;WW;55555;FF;ZZ;RR;YY GG;22222; with this .awk script (I use it in Windows with cmd) #!/usr/bin/awk -f NR != FNR { exit } { printf "%s", $0 } /^BB/ { o = "" while (getline tmp < ARGV[2]) { n = split (tmp,arr,";") for (i=1; i<=n; i++) if(!match($0,arr[i]) && !match(o,arr[i])) o=o arr[i]";" } printf "%s", o } { print "" } Usage is

How do -s and -p alter the read command?

风流意气都作罢 提交于 2021-02-17 05:36:06
问题 I'm trying to interpret this block of code. Searched google to see what these commands mean and no luck. I put my interpretation of what each line/block means to me. If I am wrong, please correct me. I am new to unix commands. Code: #!/bin/bash # input 1st command line argument for the version. export VERSION=$1 # if user didn't input a version, print the echo message and exit (not sure what -n means but I am assuming) if [[ ! -n "$VERSION" ]]; then echo "Missing Version" exit 1 fi # creating

VSCode Python开发环境配置

强颜欢笑 提交于 2021-02-17 05:31:22
博客: blog.shinelee.me | 博客园 | CSDN [TOC] 准备工作 安装anaconda , 官网 下载安装,笔者安装在"D:\Anaconda3" 安装好之后,查看环境变量path中是否有如下路径,没有的话添加进去 D:\Anaconda3 D:\Anaconda3\Scripts 安装git , 官网 下载安装,默认安装路径"C:\Program Files\Git" 安装VSCode , 官网 下载安装 VSCode初步 查看 Visual Studio Code Tips and Tricks ,快速熟悉VSCode。 用户界面 了解VSCode用户界面,如下图所示,随便点一点,还是比较一目了然的。 快捷键 Windows下的默认快捷键如下图所示, 万能Ctrl+Shift+P 。也可以 文件→首选项→键盘快捷方式, 自定义快捷键绑定 。 安装扩展 如图搜索并安装相应扩展 安装**Chinese(Simplified)**中文简体语言包,参看官方文档 Display Language 设置显示语言 安装 Python 扩展,如果前面安装的anaconda的路径已经加入到path环境变量中,这里跟着提示操作就可以,vscode会自动找到系统python的位置,调试时如果发现提示pylint没有安装,可以通过 pip 或者 conda 安装,参看

Why does command-with-error | grep 'regex-not-matching-error' still print an error?

妖精的绣舞 提交于 2021-02-17 05:13:47
问题 I am learning bash. I ran following code and got some output, $ cat non_exist_file | grep -e 'dummy' cat: non_exist_file: No such file or directory It was strange for me because I expected the output should have nothing. I have read a instruction in bash manual below, Pipelines [time [-p]] [ ! ] command [ [|⎪|&] command2 ... ] ... If |& is used, command's standard error, in addition to its standard output, is connected to command2's standard input through the pipe; it is shorthand for 2>&1 |.

Why does command-with-error | grep 'regex-not-matching-error' still print an error?

為{幸葍}努か 提交于 2021-02-17 05:12:37
问题 I am learning bash. I ran following code and got some output, $ cat non_exist_file | grep -e 'dummy' cat: non_exist_file: No such file or directory It was strange for me because I expected the output should have nothing. I have read a instruction in bash manual below, Pipelines [time [-p]] [ ! ] command [ [|⎪|&] command2 ... ] ... If |& is used, command's standard error, in addition to its standard output, is connected to command2's standard input through the pipe; it is shorthand for 2>&1 |.

Why does command-with-error | grep 'regex-not-matching-error' still print an error?

无人久伴 提交于 2021-02-17 05:11:13
问题 I am learning bash. I ran following code and got some output, $ cat non_exist_file | grep -e 'dummy' cat: non_exist_file: No such file or directory It was strange for me because I expected the output should have nothing. I have read a instruction in bash manual below, Pipelines [time [-p]] [ ! ] command [ [|⎪|&] command2 ... ] ... If |& is used, command's standard error, in addition to its standard output, is connected to command2's standard input through the pipe; it is shorthand for 2>&1 |.

Why do my Bash prompt colors make cursor appear in wrong spot [duplicate]

 ̄綄美尐妖づ 提交于 2021-02-17 03:22:36
问题 This question already has an answer here : Adding ANSI color escape sequences to a bash prompt results in bad cursor position when recalling/editing commands (1 answer) Closed 4 years ago . I've got the following bash prompt: # helper function to set colors function ps1c() { tput setaf $1; } PS1='$(ps1c 243)\h $(ps1c 177)\W $(ps1c 214)$ \[\e[m\]'; When typing, sometimes my cursor returns to the left side of the screen and looks like it's overwriting the prompt. Also, when using the up arrow