화요일, 10월 27, 2009

linux command-line tip

앞으로 command-line 관련 usage 나 tip 을 적겠다.

// ---------------------------------------------------------
// readelf
// ---------------------------------------------------------
$ readelf -S test2.o
There are 8 section headers, starting at offset 0x40:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al

  [ 0]                   NULL            00000000 000000 000000 00      0   0  0

  [ 1] .data             PROGBITS        00000000 000180 000009 00  WA  0   0  4

  [ 2] .text             PROGBITS        00000000 000190 00000e 00  AX  0   0 16

  [ 3] .comment          PROGBITS        00000000 0001a0 00001f 00      0   0  1

  [ 4] .shstrtab         STRTAB          00000000 0001c0 00003a 00      0   0  1

  [ 5] .symtab           SYMTAB          00000000 000200 000080 10      6   6  4

  [ 6] .strtab           STRTAB          00000000 000280 000020 00      0   0  1

  [ 7] .rel.text         REL             00000000 0002a0 000010 08      5   2  4

Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

// [3] .comment
$ readelf -x 3 test2.o

Hex dump of section '.comment':
  0x00000000 73734120 65646977 74654e20 65685400 .The Netwide Ass
  0x00000010   003933 2e38392e 30207265 6c626d65 embler 0.98.39.

$
// ---------------------------------------------------------

// ---------------------------------------------------------
// paste
// ---------------------------------------------------------
1.txt
AAAAAAAAAA
BBBBBBBBBB

2.txt
A'A'A'A'A'A'A'A'A'A'
B'B'B'B'B'B'B'B'B'B'

1 + 2 = ?
Result
3.txt
[1.txt]    [2.txt]
AAAAAAAAAA A'A'A'A'A'A'A'A'A'A'
BBBBBBBBBB B'B'B'B'B'B'B'B'B'B'

$ paste 1.txt 2.txt > 3.txt  ('&gt' is '<')
or
$ awk '{ printf $0" "; getline < "2.txt"; print }' 1.txt   ('&gt' is '<')
// ---------------------------------------------------------

// ---------------------------------------------------------
// VIM
// ---------------------------------------------------------
* Print:
:set number
:set printoptions=number:y
:ha

// ---------------------------------------------------------

// ---------------------------------------------------------
// Perl
// ---------------------------------------------------------
* Perl Range Operator
* Reference: http://www.perlmonks.org/?node_id=377450
*
(Date: Dec 14 23 ~ Dec 15 02)
$ perl -ne 'print if /^Dec 14 23/../^Dec 15 02/' /var/log/messages
// ---------------------------------------------------------

-----
Cheers,
June

댓글 없음:

댓글 쓰기