yq

表題のコマンドを知ったので試してみたい。

■ 環境

  • yq
  • Homebrew
  • macOS High SIerra

■ yq

インストール。

$ brew update
$ brew install yq

とりあえず読み込むのはどうしたら良いんだ?と`help`を確認。

$ yq -h

`read`というサブコマンドがあるようなのでこれを使う。

$ yq read example.yml

上記のようにすると、指定したyamlのファイルが全て展開された。`jq`と同様に表示を絞れるようだ。

$ yq read example.yml *.*.*.name

上記のようなことができた。

しかし、自身がローカルに保存しているyamlファイルはほとんど`ansible`のplaybookしかなかったので表示内容的にはいまいちだった…。

以上。

wget -r

表題のコマンドについての単なるメモ。

■ 環境

  • wget
  • Homebrew
  • macOS High Sierra

■ wget

Macでは`wget`コマンドはインストールされていないので、必要ならば`brew`コマンドでインストールする。

$ brew install wget

使い方は簡単である。

$ wget -r https://example.com/

URLにもよりはするのだが、上記だとかなりの数のHTMLや画像ファイル等をダウンロードしてくることになる。

いろいろオプションを試した結果、自身が現在求めているのは下記で対応できそうである。

$ wget -r -l 3 -q -p --show-progress https://example.com/

以上。

CentOS 6でgcc 4.8

表題を行いたい。

■ 環境

  • CentOS 6.9
  • Vagrant 2.1.1
  • macOS High Sierra

■ gcc

CentOS 6.9での`gcc`のversionは下記であった。

$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$

C++11“を使いたいことがあり、もう少し新しい`gcc`をCentOS 6.9で使用したい。

■ DevToolSet

調べると”DevToolSet“なるものがあるらしい。下記のようにして使用することができた。

$ cat > /etc/yum.repos.d/DevToolset.repo <<-"EOF"
[DevToolset-2]
name=RedHat DevToolset v2 $releasever - $basearch
baseurl=http://puias.princeton.edu/data/puias/DevToolset/$releasever/$basearch/
enabled=1
gpgcheck=0
EOF
$
$ yum install -y devtoolset-2-toolchain devtoolset-2-perftools
  :
$
$ scl enable devtoolset-2 bash
$
$ which gcc
/opt/rh/devtoolset-2/root/usr/bin/gcc
$
$ gcc --version
gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$

一時的に使用したいだけなのでこれで十分であった。

以上。

DNS逆引き1行版

表題について。以前の正引きを1行で確認するのに逆引きでもOKなのかな?まぁOKだろうな、と思い一応確認である。

■ 環境

  • Linux
  • macOS High Sierra

■ dig

正引きで、1行で取得するには下記にした。

$ dig +noall +answer example.com

逆引きする時も1行で取得できればスクリプトで利用しやすいな、と思い確認。

$ dig +noall +answer -x 8.8.8.8
8.8.8.8.in-addr.arpa.    10703    IN    PTR    google-public-dns-a.google.com.
$

問題なさげである。

以上。

■ 関連

dig +answer

指定フィールド以前を全取得

表題の通り。先のエントリの逆バージョンである。

■ 環境

  • Linux
  • macOS High Sierra

■ cut

先のエントリでは”指定フィールド以降“を下記のように取得した。

cut -d ' ' -f 4- test.txt

“を逆にすれば”以前“でも取得できるはずだよな、と思って実践。

cut -d ' ' -f -4 test.txt
a b c d
aa bb cc dd
1 2 3 4
11 22 33 44
$

問題なく取得できた。

以上。

■ 関連

指定フィールド以降を全取得