dstat

dstat dstat 是一个可以取代vmstat,iostat,netstat和ifstat这些命令的多功能产品。dstat克服了这些命令的局限并增加了一些另外的功能,增加了监控项,也变得更灵活了。dstat可以很方便监控系统运行状况并用于基准测试和排除故障。 dstat可以让你实时地看到所有系统资源,例如,你能够通过统计IDE控制器当前状态来比较磁盘利用率,或者直接通过网络带宽数值来比较磁盘的吞吐率(在相同的时间间隔内)。 dstat将以列表的形式为你提供选项信息并清晰地告诉你是在何种幅度和单位显示输出。这样更好地避免了信息混乱和误报。更重要的是,它可以让你更容易编写插件来收集你想要的数据信息,以从未有过的方式进行扩展。 Dstat的默认输出是专门为人们实时查看而设计的,不过你也可以将详细信息通过CSV输出到一个文件,并导入到Gnumeric或者Excel生成表格中。 https://linux.cn/article-3215-1.html pacman -S dstat

2012-11-13 · 1 min · 10 words · -

xrandr

‘Linux 双显示器/多屏/扩展屏幕/xrandr’ Can’t open display :0 用 root 用户执行 xrandr 会报错 Can’t open display :0, 尝试用其它普通用户 https://www.reddit.com/r/linux4noobs/comments/lu1plx/hi_i_get_this_authorization_required_but_no/ 4k 显示器调整 dpi xrandr -display :0.0 --listmonitors xrandr -display :0 --listmonitors xrandr -display :0 --dpi 144 # 或者这样配置环境变量 export DISPLAY=:0 xrandr --listmonitors xrdb -query xdpyinfo|grep dots xdpyinfo | grep -B 2 resolution xrandr -verbose xrandr -output DVI-0 -left-of VGA-0 -auto 不带参数执行xrandr能够列出当前的显示设备和每个设备支持的模式。 edit xorg.conf add line Virtual 2560 1024 wiloon@debian:~$ xrandr Screen 0: minimum 320 x 200, current 1680 x 1050, maximum 16384 x 16384 DFP1 connected 1680x1050+0+0 (normal left inverted right x axis y axis) 518mm x 324mm 1920x1200 60.0 + 1920x1080 60.0 1600x1200 60.0 1680x1050 60.0* 1400x1050 60.0 1600x900 60.0 1360x1024 60.0 1280x1024 60.0 1440x900 60.0 1280x960 60.0 1280x800 60.0 1280x768 60.0 1280x720 60.0 1024x768 60.0 800x600 60.3 640x480 59.9 DFP2 disconnected (normal left inverted right x axis y axis) DFP3 disconnected (normal left inverted right x axis y axis) DFP4 disconnected (normal left inverted right x axis y axis) DFP5 connected 1680x1050+0+0 (normal left inverted right x axis y axis) 408mm x 255mm 1680x1050 60.0*+ 1600x1200 60.0 1400x1050 60.0 1600x900 60.0 1360x1024 60.0 1280x1024 75.0 60.0 1440x900 59.9 1280x960 60.0 1280x800 60.0 1152x864 60.0 75.0 1280x768 60.0 1280x720 60.0 1024x768 75.0 70.1 60.0 800x600 72.2 75.0 60.3 56.2 640x480 75.0 72.8 66.6 59.9 CRT1 disconnected (normal left inverted right x axis y axis) wiloon@debian:~$ xrandr -output DFP1 -auto -left-of DFP5 xrandr -output DFP1 -mode 1920x1200 -left-of CRT2 -mode 1680x1050 wiloon@debian:~$ cvt 1680 1050 # 1680x1050 59.95 Hz (CVT 1.76MA) hsync: 65.29 kHz; pclk: 146.25 MHz Modeline "1680x1050_60.00" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync wiloon@debian:~$ xrandr -newmode "1680x1050" 146.25 1680 1784 1960 2240 1050 1053 1059 1089 -hsync +vsync wiloon@debian:~$ xrandr -addmode VGA1 "1680x1050" wiloon@debian:~$ xrandr -output VGA1 -mode 1680x1050 设置显示分辨率及 xrandr 介绍 X Windows 中有一个显示分辨率的概念,在默认情况下,这个显示分辨率为 max*max ,max等于你的所有连接上的显示器中最大分辨率中的最大值。例如我的笔记本液晶屏最大分辨率为 1024*768,外接显示器最大分辨率为 1280*1024,则默认的显示分辨率为 1280*1280。如果我设置左右双屏且使用最大分辨率,那么总显示分辨率就会达到2304*1024,达到超出系统默认的大小。在这种情况下强行设置双屏幕,就会导致 X 进入超低分辨率,结果不得不手工重设 xrog.conf 来恢复。 为了更好检测这个问题,我们需要用到xrandr 这个软件,xrandr系统已经自带,如果没有请安装x11-xserver-utils: sudo apt-get install x11-xserver-utils 。 不带参数执行xrandr能够列出当前的显示设备和每个设备支持的模式。Screen代表了总显示区域,VGA代表显示器,LVDS代表笔记本液晶屏。 ...

2012-11-11 · 4 min · 765 words · -

Beelink SER8 archlinux

文档说明: 本文档记录 Beelink SER8 mini PC 在 Arch Linux + KDE 桌面环境下使用过程中遇到的问题、解决方案和系统操作。 亮度自动降低问题解决方案 问题描述 系统在锁屏、关闭显示器或重启后,显示器亮度会被自动调低到 30% 左右,且不会自动恢复。 环境信息 设备: Beelink SER8 (mini PC) 系统: Arch Linux 桌面环境: KDE Plasma 亮度控制: DDC/CI (通过 ddcutil) 解决方案 方案 1: 禁用 KDE 的自动亮度调节 (推荐) 打开 KDE 系统设置: systemsettings5 导航到: 电源管理 (Power Management) → 节能 (Energy Saving) 检查以下设置: 取消勾选 “当空闲时降低屏幕亮度” (Dim screen when idle) 取消勾选 “在锁定屏幕时降低亮度” (Dim screen on lock) 在 “屏幕亮度” 部分,将所有电源模式下的亮度设置为你想要的值(如 100%) 点击 “应用” 保存设置 ...

2012-10-29 · 20 min · 4151 words · lcf

GNU profiler

GNU profiler 各种软件对于性能的需求可能会有很大的区别,但是很多应用程序都有非常严格的性能需求,这一点并不奇怪。电影播放器就是一个很好的例子: 如果一个电影播放器只能以所需要速度的 75% 来播放电影,那么它几乎就没什么用处了。 其他应用程序 (例如视频编码) 如果是耗时非常长的操作,最好以 “批处理” 任务的方式运行,此时启动一个作业,让其一直运行,然后我们就可以去干别的事情了。尽管这些类型的应用程序没有这种硬性性能指标的限制,但是提高速度仍然会带来很多好处,例如可以在给定的时间内可以对更多电影进行编码,在同样的时间内可以以更高的品质进行编码。 通常,除了最简单的应用程序之外,对于其他应用程序来说,性能越好,这个应用程序的用处就越大,也就会越流行。由于这个原因,性能考虑是 (也应该是) 很多应用程序开发人员脑袋中的第一根弦。 不幸的是,很多尝试让应用程序速度更快的努力都白费了,因为开发人员通常都是对自己的软件进行一些_小型的优化_,而没有去研究程序在更大的范围内是如何操作的。例如,我们可能会花费大量的时间来让某个特定函数的运行速度达到原来的两倍,这一点非常不错,但是如果这个函数很少被调用 (例如打开文件) ,那么将这个函数的执行时间从 200ms 减少到 100ms,对于整个软件的总体执行时间来说并不会有太大的影响。 有效地利用您的时间的方法是,尽量优化软件中被频繁调用的部分。例如,假设应用程序花了 50% 的时间在字符串处理函数上,如果可以对这些函数进行优化,提高 10% 的效率,那么应用程序的总体执行时间就会改进 5%。 因此,如果希望能够有效地对程序进行优化,那么精确地了解时间在应用程序中是如何花费的,以及_真实的输入数据_,这一点非常重要。这种行为就称为_代码剖析 (code profiling) _。本文将简要介绍 GNU 编译器工具包所提供的一种剖析工具,它的名字让人可以产生无限遐想,叫 GNU profiler (gprof) 。

2012-10-15 · 1 min · 36 words · -

Dmidecode,在 Linux 下获取硬件信息

‘Dmidecode,在 Linux 下获取硬件信息’ http://linuxtoy.org/archives/dmidecode.html Dmidecode 应该在主流的 Linux 发行版中都可以找到,因此你只需通过所用发行版的包管理器安装即可,如: pacman -S dmidecode # Arch Linux emerge -av dmidecode # Gentoo aptitude install dmidecode # Debian/Ubuntu yum install dmidecode # Fedora 不带选项执行 dmidecode 通常会输出所有的硬件信息,以下是在笔者机器上执行 dmidecode 后所得到的结果 (部分) : # dmidecode 2.10 SMBIOS 2.3 present. 26 structures occupying 1285 bytes. Table at 0x000FC010. Handle 0x0000, DMI type 0, 24 bytes BIOS Information Vendor: American Megatrends Inc. Version: 080012 Release Date: 02/06/2007 Address: 0xF0000 Runtime Size: 64 kB ROM Size: 512 kB ... Dmidecode 有个很有用的选项 -t,可以按指定类型输出相关信息,假如要获得处理器方面的信息,则可以执行 ...

2012-09-25 · 1 min · 201 words · lcf

linux 内存

linux 内存 linux 查看内存 top free -h # 内存的更具体的使用情况 cat /proc/meminfo dmidecode -t memory dmidecode |grep -A16 "Memory Device$" 进程内存占用 top ps aux | grep containerd ps -o pid,user,%mem,rss,vsz,comm -C containerd pmap PID #ps ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid' 其中rsz是是实际内存 ps -e -o 'pid,comm,args,pcpu,rsz,vsz,stime,user,uid' | grep oracle | sort -nrk5 其中rsz为实际内存,上例实现按内存排序,由大到小 sudo pacman -S htop # Arch Linux htop # 实时查看 containerd 服务的资源占用 systemd-cgtop # 只看 containerd 相关的 systemd-cgtop | grep containerd yay -S smem sudo smem -t -k -c "pid user command rss pss uss" | grep containerd 内存映射 cat /proc/PID/maps cat /proc/PID/smaps free> total 跟物理内存不一致 系统启动时会初始化相关设备,该过程会占用内存,内核启动时,也会占用一部分的内存。 ...

2012-09-25 · 1 min · 98 words · lcf

linux下用adb为android手机批量安装软件

linux下用adb为android手机批量安装软件 通常大家安装软件都是从Andorid Market或者从网上下载到手机本地安装,这有两个问题,第一个情况碰到网速慢,那要急死,第二种情况是安装的太慢,如果软件多的话,手指累死,那么,就用adb安装吧,看我的操作情况: 首先把以前安装的软件备份到电脑,比如~/backup/,接着,打开电脑上的终端,取得root权限, cd adb ./adb start-server 打开另一个终端,默认用户权限 $ cd adb $ sh install.sh (-sh里面的内容如这样: ./adb install ~/backup/***.apk……,把你要装的软件都这样编辑,一行一个软件) ok,等着吧,安装完,切换到第一个终端,执行 ./adb kill-server 安全移除手机,看看手机上是不是已经显示你安装的软件了,呵呵

2012-09-24 · 1 min · 23 words · -

linux 时区,时间

linux 时区,时间 # 把硬件时间设置成系统时间 hwclock --hctosys # 把系统时间设置成硬件 hwclock --systohc # 设置硬件时间 hwclock --set --date="mm/dd/yy hh:mm:ss" # 修改系统时间 date -s "dd/mm/yyyy hh:mm:ss" timedatectl 设置时区 # 查看系统时间方面的各种状态 timedatectl timedatectl status # 列出所有时区 timedatectl list-timezones # 设置系统时区为上海 timedatectl set-timezone Asia/Shanghai timesync sudo systemctl restart systemd-timesyncd systemctl status systemd-timesyncd timedatectl show-timesync timedatectl timesync-status https://www.linuxuprising.com/2019/07/how-to-set-timezone-and-enable-network.html timedatectl set-local-rtc 1 # 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间 其实不考虑各个发行版的差异化, 从更底层出发的话, 修改时间时区比想象中要简单: cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ...

2012-09-24 · 2 min · 397 words · lcf

Revolution OS操作系统革命

Revolution OS操作系统革命 操作系统革命的剧情简介 · · · · · · 内容简介(来自http://blog.9zi.com/post/1/979) : 在微软垄断下有一件东西永远它永远不会给你――真正的自由。也正是因为这个原因,不少先锋人物站出来反抗微软帝国,并努力建立一种新的操作系统――没有人为的限制,任何人都可以自由地使用。 为了记录这些人的艰苦历程,J.T.S. Moore拍摄了全新的记录片――REVOLUTON OS,向公众介绍这些建立Linux操作系统,奋起反抗垄断的斗士的人生经历。 现在微软已经明显感到了来自Linux的压力。微软的首席执行官去年6月公开表示: “Linux 是一种癌症!"。但这丝毫不能影响Linux发展的步伐。 REVOLUTION OS中记录了Linux的创建人Linus Torvalds以及Richard Stallman, Bruce Perens, Eric Raymond, Brian Behlendorf, Michael Tiemann, Larry Augustin, Frank Hecker, Rob Malda等人的生活经历或者采访记录。 http://movie.douban.com/subject/1437389/

2012-09-22 · 1 min · 37 words · -

在WSL2中安装ArchLinux

在WSL2中安装ArchLinux https://zhuanlan.zhihu.com/p/266585727 https://github.com/DDoSolitary/LxRunOffline .\LxRunOffline i -n archlinux -f C:\workspace\apps\archlinux-bootstrap-2022.02.01-x86_64.tar.gz -d C:\workspace\apps\wsl-archlinux -r root.x86_64 wsl --set-version archlinux 2 wsl -d archlinux lxrunoffline su -n archlinux -v 1000

2012-09-21 · 1 min · 26 words · -

使用 arpalert 来做被动式arp防火墙

使用 arpalert 来做被动式arp防火墙 http://forum.ubuntu.org.cn/viewtopic.php?f=116&t=110347&sid=ae4c75fe6a8b5aa1672e8a05bc6f7d85 我说的被动式是指在探测到欺骗时做出防护动作 在局域网环境中 arp 欺骗是个很头疼的问题, 尤其是网关不是自己控制的时候. 虽然自己可以绑定网关, 但是网关就没办法了. 结果导致网关的东西传不回来, 无法上网. 原理: arpalert 监听网卡收到的 arp 包, 并根据规则(黑白名单等)调用一个防护脚本. 安装: 安装以下包: libnet-arp-perl arpalert(建议用最新的 2.0.11 版, 2.0.10 前的版本处理名单时有问题) 另外将以下文本存为 /usr/local/sbin/arpdef.pl 加上可执行权限(755) [perl] #!/usr/bin/perl -w use strict; if ( $< ) { print “$0n”; system(“sudo”,($0,@ARGV)); exit; } my $mac = $ARGV[0]; my $ip = $ARGV[1]; my ($gateip,$gatemac) = (“192.168.6.1”,“00:04:80:FA:3C:00”); exit 0 if ((“U$mac” eq “U$gatemac”) && ($ip eq $gateip)); #logging .. my $date=`date +"%F %T"`; ...

2012-09-19 · 5 min · 1059 words · -

公有云安装 archlinux, Aliyun/阿里云 ecs, bwg KVM

aliyun ecs, 阿里云安装 archlinux aliyun vm 安装 非 EFI 的镜像 cd /tmp curl -O http://mirrors.163.com/archlinux/iso/2024.04.01/archlinux-bootstrap-2024.04.01-x86_64.tar.gz tar zxvf archlinux-bootstrap-xxx.tar.gz # 要用 mount --bind 把 RootFS 解包的目录自己与自己链接起来,不然 pacman 会装不了软件 sudo mount --bind /tmp/root.x86_64 /tmp/root.x86_64 # edit mirror list vim /tmp/root.x86_64/etc/pacman.d/mirrorlist # chroot /tmp/root.x86_64/bin/arch-chroot /tmp/root.x86_64/ # 初始化 pacman 的密钥 pacman-key --init pacman-key --populate archlinux # 把 原系统的 根目录 / 挂载到 /mnt # 先 df -h 看一下 根目录在哪个分区 mount /dev/vdaX /mnt # 保留的目录 /dev /proc /run /sys /tmp , 这些目录都是存储到硬件的映射的,所以不能删 # boot 目录有可能会删除失败 rm -rf /mnt/boot rm -rf /mnt/bin rm -rf /mnt/data rm -rf /mnt/etc rm -rf /mnt/home rm -rf /mnt/lib rm -rf /mnt/lib32 rm -rf /mnt/lib64 rm -rf /mnt/libx32 rm -rf /mnt/media rm -rf /mnt/mnt rm -rf /mnt/opt rm -rf /mnt/root rm -rf /mnt/sbin rm -rf /mnt/srv rm -rf /mnt/usr rm -rf /mnt/var pacstrap /mnt base linux linux-firmware genfstab -U /mnt >> /mnt/etc/fstab arch-chroot /mnt ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime echo 'nameserver 114.114.114.114' >> resolv.conf pacman -S gvim openssh grub sudo neofetch python echo 'aliyun0' > /etc/hostname echo '127.0.0.1 localhost' >> /etc/hosts echo '127.0.0.1 aliyun0' >> /etc/hosts systemctl enable systemd-networkd systemctl enable systemd-resolved systemctl enable sshd vim /etc/systemd/network/eth.network [Match] Name=en* [Network] DHCP=ipv4 [DHCPv4] UseHostname=false useradd -m wiloon passwd wiloon passwd root echo 'wiloon ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/wiloon.conf grub-install --target=i386-pc /dev/vda grub-mkconfig -o /boot/grub/grub.cfg reboot timedatectl set-ntp true -` root@aliyun0 .o+` ------------ `ooo/ OS: Arch Linux x86_64 `+oooo: Host: Alibaba Cloud ECS pc-i440fx-2.1 `+oooooo: Kernel: 6.8.7-arch1-1 -+oooooo+: Uptime: 6 mins `/:-:++oooo+: Packages: 254 (pacman) `/++++/+++++++: Shell: bash 5.2.26 `/++++++++++++++: Resolution: 1024x768 `/+++ooooooooooooo/` Terminal: /dev/pts/0 ./ooosssso++osssssso+` CPU: Intel Xeon Platinum 8269CY (2) @ 2.500GHz .oossssso-````/ossssss+` GPU: 00:02.0 Cirrus Logic GD 5446 -osssssso. :ssssssso. Memory: 93MiB / 422MiB :osssssss/ osssso+++. /ossssssss/ +ssssooo/- `/ossssso+/:- -:/+osssso+- `+sso+:-` `.-/+oso: `++:. `-/+/ .` `/ https://limelight.moe/t/topic/6007 https://www.scarletdrop.cn/archives/14 ...

2012-09-16 · 2 min · 305 words · -

kvm 虚拟机 vnc 开启音频 +rdp

kvm虚拟机vnc开启音频+rdp 为了方便使用virt-manager来创建和管理kvm的虚拟机。默认创建好的windows xp虚拟机,用vnc连接的时候会没有声音,用rdesktop连接的时候声音是正常的。 查了一些发行版的bugzilla,发现相关的bug还真有不少,在fedora的wiki上找到了解决方法 (原始链接在这里) : 修改/etc/libvirt/qemu.conf文件中的vnc_allow_host_audio为1,然后重启libvirtd服务,就OK了。不过这样设置以后,即使不打开virt-manager的vnc客户端,也能够听到虚拟机中发出的声音。 If you have a Linux computer and sound is working on it, then you will be able to get sound through rdesktop. But it’s not necessary easy, unless you are aware that there is a bug that prevents it. Good news is that there is a really simple work-around to make sound work. To get sound to work through rdesktop, first make sure Windows is configured to pass sound through Remote Desktop. Open up “Control Panel” -> “Sounds and Audio Devices”. You should see “Microsoft RDP Audio Driver”. Next, if the “Device volume” is set to “Low”, it is either because: 1) sound pass-through is not enabled; or 2) you reduced the volume to “Low”. Try fixing #2 by moving the slider to “High”, then click the “Apply” button. If the slider stays at “High”, then it’s #2 and you should now have sound. If the slider jumps back to “Low” then it’s #1 (continue to next paragraph). ...

2012-09-13 · 2 min · 336 words · -

archlinux vm template

archlinux vm template archlinux openssh systemctl enable sshd python vim ssh-key, ed25519 neovim ncdu

2012-09-13 · 1 min · 14 words · -

Debian系统回收站无法清空解决办法

Debian系统回收站无法清空解决办法 Debian系统回收站无法清空: (1) 切换到root身份 su - (2) chown -R wiloon /home/wiloon/.local/share/Trash (3) 退出su权限 exit (4) chmod -R +w /home/wiloon/.local/share/Trash (5) 接下来就可以去清空回收站了 rm -rf /home/wiloon/.local/share/Trash/files/*

2012-08-16 · 1 min · 24 words · -

linux game alien arena

linux game alien arena Alien Arena 2011 7.50版本发布,这款开源的游戏新版本带来了以下特色:新增的物理引擎 ,改善的游戏IRC客户端,GUN的自动化安装工具,以便Linux/Unix/Macos下的安装,新的True Type字体支持,2张全新的地图,1张修改善的地图,著名音乐人Paul Joyce带来的全新游戏音乐. Alien Arena介绍: 一款免费开源的第一人称射击游戏(FPS),使用改动的id Tech2,行动和武器方面非常相似<雷神之锤II>,也拥有全部的跳跃技巧 更多的介绍:http://zh.wikipedia.org/zh/Alien_Arena 1 编译: sudo apt-get build-dep alien-arena 2 安装额外的依赖 sudo apt-get install libode-dev 3 安装 ./configure make sudo make install 4 打开终端,输入crx,开始享受吧

2012-07-15 · 1 min · 37 words · -

size

size size 程序列出参数列表中各目标文件或存档库文件的段大小 — 以及总大小。默认情况下,对每个目标文件或存档库中的每个模块都会产生一行输出。 size foo wiloonwy@penguin:~/tmp$ size foo text data bss dec hex filename 1458 584 8 2050 802 foo 前三部分的内容是文本段、数据段和 bss 段及其相应的大小。然后是十进制格式和十六进制格式的总大小。最后是文件名。 size foo --format=SysV foo : section size addr .interp 28 792 .note.gnu.property 64 824 .note.gnu.build-id 36 888 .note.ABI-tag 32 924 .gnu.hash 28 960 .dynsym 168 992 .dynstr 130 1160 .gnu.version 14 1290 .gnu.version_r 32 1304 .rela.dyn 192 1336 .rela.plt 24 1528 .init 27 4096 .plt 32 4128 .text 405 4160 .fini 13 4568 .rodata 17 8192 .eh_frame_hdr 52 8212 .eh_frame 216 8264 .init_array 8 15848 .fini_array 8 15856 .dynamic 480 15864 .got 40 16344 .got.plt 32 16384 .data 16 16416 .bss 8 16432 .comment 18 0 .debug_aranges 48 0 .debug_info 140 0 .debug_abbrev 67 0 .debug_line 86 0 .debug_str 133 0 .debug_line_str 123 0 Total 2717

2012-07-12 · 1 min · 131 words · -

linux shell 进程监控

linux shell 进程监控 进程内存占用 top -p <PID> # 查看进程的status文件 cat /proc/2913/status http://www.ibm.com/developerworks/cn/linux/l-cn-shell-monitoring/index.html?ca=drs- function GetPID #User #Name { PsUser=$1 PsName=$2 pid=\`ps -u $PsUser|grep $PsName|grep -v grep|grep -v vi|grep -v dbxn |grep -v tail|grep -v start|grep -v stop |sed -n 1p |awk '{print $1}'\` echo $pid } function killJboss { jbosspid=\`ps -ef | grep -i jboss | grep -v grep |grep -v killJboss.sh | awk '{print $2}'\` if [ "$jbosspid" != "" ]; then echo "Killing Jboss." echo $jbosspid for pid in $jbosspid do kill -9 $pid done fi } function GetCpu { CpuValue=\`ps -p $pid -o pcpu |grep -v CPU | awk '{print $1}' | awk -F. '{print $1}'\` echo $CpuValue } function GetMem { MEMUsage=\`ps -o vsz -p $1|grep -v VSZ\` (( MEMUsage /= 1000)) echo $MEMUsage } 检测进程句柄使用量 ...

2012-07-05 · 2 min · 352 words · -

awk command

awk command [ɔk] 参数 -F fs, --field-separator=fs, # 指定输入文件折分隔符,fs 是一个字符串或者是一个正则表达式 print ‘{pirnt $2}’, print 外层要用单引号, 不能用双引号 $0 代表当前行 内建变量 NF 一条记录的字段的数目 commands #最短行: awk '(NR==1||length(min)>length()){min=$0}END{print min}' data.txt # 最长行: awk '{if (length(max)<length()) max=$0}END{print max}' data.txt # 单独使用 awk, 不需要 cat awk '{print $1}' /tmp/foo.txt cat dep-clean|awk -F '@' '{if(NF>2){print "\"""@"$2"\""":"$3} else {pint $1":"$2}}' cat dep-clean|awk -F '@' '{if(NF<3){print "\""$1"\""":"$2}}' cat dep-clean|awk -F '@' '{if(NF>2){print "\"""@"$2"\""":"$3} else if (NF<3) {print $1":"$2}}' # kill all java process ps -ef |grep java|awk '{print $2}'|xargs -t -n 1 kill -9 # 取本机ip >https://www.cnblogs.com/poloyy/p/12212868.html ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}' # print column range awk '{for(i=1;i<=NF-1;i++) printf $i" "; print ""}' marks.txt # 统计每一行逗号出现的次数 awk -F "," '{pirnt NF-1}' foo.txt 变量 除了 $ + 数字表示某个字段,awk 还提供其他一些变量。 ...

2012-07-05 · 5 min · 947 words · -

linux shell split string

linux shell split string sentence="This is a sentence." for word in $sentence do echo $word done `` this is a sentence.

2012-07-04 · 1 min · 21 words · -