LoginSignup
1
2

More than 3 years have passed since last update.

sedやawkと踊(ダンス)っちまった時に見るページ

Last updated at Posted at 2021-04-28

でえじょうだ、どうせみんな大して使いこなせねえ。

sed

sed -n 😀p

  • 😀行目のみを出力する
    • 最初の行の行番号は1
意味
sed -n 2p 2行目を出力する

sed -e 's/😀/😍/g'

  • 「パターン😀」を「文字列😍」に置換する
  • パターンは正規表現も使えるみたい
  • / の区切りは、 # などの他の記号も使える
意味
sed -e 's/xxx/yyy/g' xxxyyy に置換する
sed -e 's#/#:#g' /: に置換する

awk

awk -F'😀' '{ print $😍 }'

  • 行を😀で分割して、😍列目を出力する
  • -F を省略するとスペースで分割する
意味
awk -F',' '{ print $2 }' ,で分割して、2列目を出力
awk '{ print $3 }' スペースで分割して、3列目を出力
1
2
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
1
2