Skip to content

Instantly share code, notes, and snippets.

@greymd
Last active June 11, 2022 23:36
Show Gist options
  • Save greymd/79ebdeb31ea08538c76e546ae469ced6 to your computer and use it in GitHub Desktop.
Save greymd/79ebdeb31ea08538c76e546ae469ced6 to your computer and use it in GitHub Desktop.
通常のpingで「にゃーん」を表示するシェル芸
#!/bin/bash
# From: https://twitter.com/grethlen/status/906154326975905793
sudo ping -i 0 -c 1400 pong4.kooshin.net \
| grep -oP "icmp_seq=\K\d+" \
| cat - <(seq 1 1400) \
| sort -n \
| uniq -c \
| awk '{printf $1}' \
| fold -w70 \
| tr '12' 'U!'
@greymd
Copy link
Author

greymd commented Sep 8, 2017

Ciscoのルータのようにアニメーションっぽく。

sudo ping -i 0 -c 1400 pong4.kooshin.net | grep --line-buffered -oP "icmp_seq=\K\d+" | awk '{n=$1-lst;print "!"; for(i=0;i<n-1;i++){print "U"}}{lst=$1;fflush()}' | awk '{printf $0}NR%70==0{print "";fflush()}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment