- Cheat Sheet and Example is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools






Linux Commands Cheat Sheet

nkf - How to use nkf command in Linux

nkf Command OPTIONS

# nkf --help

Usage:  nkf -[flags] [--] [in file] .. [out file for -O flag]

 j/s/e/w  Specify output encoding ISO-2022-JP, Shift_JIS, EUC-JP
          UTF options is -w[8[0],{16,32}[{B,L}[0]]]

 J/S/E/W  Specify input encoding ISO-2022-JP, Shift_JIS, EUC-JP
          UTF option is -W[8,[16,32][B,L]]

 L[uwm]   Line mode u:LF w:CRLF m:CR (DEFAULT noconversion)

 --overwrite[=SUF]      Preserve timestamp of original files
 -g --guess             Guess the input code
 -v --version           Print the version
 --help/-V              Print this help / configuration
# man nkf

           Specify input and output encodings. Upper case is input.
           -J  ISO-2022-JP (JIS code).

           -S  Shift_JIS and JIS X 0201 kana.  EUC-JP is recognized as X0201
               kana. Without -x flag, JIS X 0201 Katakana (a.k.a.halfwidth
               kana) is converted into JIS X 0208.  If you use Windows, see
               Windows-31J (CP932).

           -E  EUC-JP.

           -W  UTF-8N.

       -L[uwm] -d -c
           Convert line breaks.

           -Lu -d
               unix (LF)

           -Lw -c
               windows (CRLF)

           -Lm mac (CR)

nkf command Examples

Check Character

$ nkf -g test.txt

Change CharacterFrom

To UTF-8, LF

nkf -w -Lu --overwrite test.txt


# nkf -e -Lu utf8.txt > euc-jp.txt
# nkf -ed utf8.txt > euc-jp.txt

-Lu = -d

To Windows, CRLF

nkf  -s -Lw --overwrite test.txt


# To UTF8
find . -type f -name "*sh*" -print0 | xargs -0 nkf --overwrite -w -Lu

os/linux/command/nkf.html.txt ยท Last modified: 2020/02/07 by admin

Page Tools