echo

How to store output from printf with formatting in a variable? [duplicate]

房东的猫 提交于 2020-01-01 16:56:30
问题 This question already has answers here : I just assigned a variable, but echo $variable shows something else (7 answers) Closed 4 years ago . I would like to store the output of printf with formatting in a variable, but it strips off the formatting for some reason. This is the correct output $ printf "%-40s %8s %9s %7s" "File system" "Free" "Refquota" "Free %" File system Free Refquota Free And now the formatting is gone $ A=$(printf "%-40s %8s %9s %7s" "File system" "Free" "Refquota" "Free %

Ambassador系列-05-负载均衡

会有一股神秘感。 提交于 2020-01-01 14:25:49
Ambassador支持多种负载均衡算法。 round_robin,轮询算法,依次把客户端的请求分发到不同的上游服务实例。 least_request,最少请求算法,请求会被转发到请求数最少的上游服务实例。 ring_hash,会话亲和算法,可以根据hash、http头,Cookie或者实际的源IP地址,始终转发同一个上游服务实例。 负载均衡配置即可全局配置,也可以基于Service配置。 重新部署echo服务,将echo的副本数设为2。 vi echo-server-service.yaml apiVersion: v1 kind: Service metadata: labels: app: echo name: echo spec: ports: - port: 8080 name: high protocol: TCP targetPort: 8080 - port: 80 name: low protocol: TCP targetPort: 8080 selector: app: echo --- apiVersion: apps/v1beta1 kind: Deployment metadata: labels: app: echo name: echo spec: replicas: 2 selector: matchLabels: app: echo

AIX操作系统的CPU、Memory、Filesystem、Paging、I/O监控

大憨熊 提交于 2020-01-01 12:42:18
项目地址: https://github.com/zhangrj/Aix-Monitor 1、CPU使用率 CPU使用率 = 100% – CPU idle time CPU ilde time可取4秒内的平均值。例如: root@**:/ # vmstat 1 4 System configuration: lcpu=32 mem=63488MB kthr memory page faults cpu ----- ----------- ------------------------ ------------ ----------- r b avm fre re pi po fr sr cy in sy cs us sy id wa 0 0 9247706 3838878 0 0 0 0 0 0 3 321 300 0 0 99 0 0 0 9247706 3838876 0 0 0 0 0 0 10 145 302 0 0 99 0 0 0 9247706 3838876 0 0 0 0 0 0 2 54 279 0 0 99 0 0 0 9247706 3838876 0 0 0 0 0 0 3 78 285 0 0 99 0 写成脚本: #!/bin/ksh cpu_idle_list=$(/usr/bin/vmstat 1 4 | egrep -v '[a-z,A-Z]

How to print two arrays side by side with bash script?

南笙酒味 提交于 2020-01-01 09:32:08
问题 I couldn't find a good and simple answer to this question neither on google nor here on stackoverflow. Basically I have two arrays that I need to print into the terminal side by side since one array is a list of terms and the other the terms's definitions. Does anyone know a good way of doing this? Thanks in advance. 回答1: You can use a C-style for loop to accomplish this, assuming both arrays are the same length: for ((i=0; i<=${#arr1[@]}; i++)); do printf '%s %s\n' "${arr1[i]}" "${arr2[i]}"

How to get realtime output from php as it happens?

孤人 提交于 2020-01-01 05:16:33
问题 How to get real-time output from php as it happens ? without storing all in memory/buffer and echoing all at once to the browser ? if i create a realtime-echo.php <?php for($i = 0; $i < 10; $i++) { echo $i; sleep(1); } and access it from Internet browser it gives following output , after 9-10 seconds. 0123456789 but what i am willing the output to be is, when i access the php file from my browser it should give 0 then wait 1 second then add "1" after the "0" then wait 1 second then add "2"

How do I overwrite multiple lines in a shell script?

旧街凉风 提交于 2020-01-01 00:39:08
问题 I want to write multiple lines over and over to the terminal. Something like echo "One Line" echo "Two Lines" echo "\r\b\rThree Lines" echo "Four Lines" Ideally this would first output: One Line Two Lines And this output would then be replaced with Three Lines Four Lines Trouble is, while the carriage return will let you overwrite one line of output, you can't get past the \n with a \b. How do I then overwrite multiple lines? 回答1: I found a solution for this one that took a little digging and

Echo command, and then run it? (Like make)

穿精又带淫゛_ 提交于 2019-12-31 19:44:00
问题 Is there some way to get bash into a sort of verbose mode where, such that, when it's running a shell script, it echoes out the command it's going to run before running it? That is, so that it's possible to see the commands that were run (as well as their output), similar to the output of make ? That is, if running a shell script like echo "Hello, World" I would like the following output echo "Hello, World" Hello, World Alternatively, is it possible to write a bash function called echo_and

写一个脚本,实现判断192.168.3.0/24网络里,当前在线的IP有哪些。

拟墨画扇 提交于 2019-12-31 17:50:00
条件如下: 通过ping命令测试192.168.3.1到192.168.3.5之间的所有主机是否在线, 如果在线,就显示"ip is up.",其中的IP要换为真正的IP地址,且以绿色显示; 如果不在线,就显示"ip is down.",其中的IP要换为真正的IP地址,且以红色显示; 要求:分别使用while,until和for(两种形式)循环实现。 方法一:用while实现。 #!/bin/bash IP=1 while [ $IP -le 5 ] ; do ping - c 2 - w 2 192 . 168 . 3 . $IP &> / dev / null STRING=$? # if ping -w 2 -c 2 192.168.3.$IP &>/dev/null;then if [ $STRING -eq 0 ] ; then echo - e "\033[32;40m192.168.3. $IP is up.\033[0m" else echo - e "\033[31;40m192.168.3. $IP is down.\033[0m" fi let IP= $IP + 1 done 或者 : #!/bin/bash # while true ; do for I in { 1 . . 5 } ; do ping - c 2 - w 2 192 . 168 . 3

Bat01————认识echo

自闭症网瘾萝莉.ら 提交于 2019-12-31 15:24:10
要频繁用到adb命令,重复性的,于是想到了bat脚本,因为简单,方便,不用我一遍一遍的输入命令 bat脚本很简单 @echo off 代表的是关闭所有命令的回显 举例说明 @echo off @echo off echo 第一条命令 echo 第二条命令 echo 第三条命令 echo 第四条命令 echo 第五条命令 echo 第六条命令 pause 结果: echo off echo off echo test1 echo test2 echo test3 echo test4 echo test5 echo test6 pause 结果: @echo on @echo on echo test1 echo test2 echo test3 echo test4 echo test5 echo test6 pause 区别就是命令行显示的方式 我使用的脚本是: @echo on echo ****start**** adb shell uiautomator dump /sdcard/app.uix adb pull /sdcard/app.uix C:\Users\GV-RD-01\Desktop\screen adb shell screencap -p /sdcard/app.png adb pull /sdcard/app.png C:\Users\GV-RD-01

PHP concatenation

血红的双手。 提交于 2019-12-31 07:57:47
问题 I am trying to get into some PHP and I can't seem to figure out the following. I can create a string by means of PHP with concatenation: echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n"; But what if you want to do this with a variable? (I am guessing WP's functions can be called variables.) I am quite lost here. The following does not work. Or at least, my text editor throws an unknown error. <?php if ( is_404() ) { echo "<script src='" . get_stylesheet_directory_uri