0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【1行野郎】ldd で表示されるライブラリの合計サイズを算出する

Last updated at Posted at 2021-08-14

処理内容

下記の場合だと libgtk3-nocsd.so.0、libexpect.so.5.45、、、といった
ファイルのサイズの合計値を求める

$ ldd /usr/bin/expect
	linux-vdso.so.1 (0x00007ffc27fc5000)
	libgtk3-nocsd.so.0 => /usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 (0x00007f10722bb000)
	libexpect.so.5.45 => /usr/lib/x86_64-linux-gnu/libexpect.so.5.45 (0x00007f107208b000)
	libtcl8.6.so => /usr/lib/x86_64-linux-gnu/libtcl8.6.so (0x00007f1071cda000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f10718e9000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f10716e5000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f10714c6000)
	libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f10712c3000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1070f25000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f1070d08000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f10726c5000)

コード

$ LANG=C ldd /usr/bin/expect |
  sed -r -n 's/(.*) => (.*) \((.*)\)/\2/p' |
  xargs -I@ realpath @ |
  xargs -I@ ls -ltr @ |
  awk '{i += $5 } END { print i }'

実行結果

$ LANG=C ldd /usr/bin/expect | sed -r -n 's/(.*) => (.*) \((.*)\)/\2/p' | xargs -I@ realpath @ | xargs -I@ ls -ltr @ | awk '{i+=$5 } END { print i }'
5998352
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?