LoginSignup
0

More than 5 years have passed since last update.

snippet: perl

Last updated at Posted at 2015-07-13

改行を削除

perl -pe 's/\n//g' a.txt

置換

不要な文字削除
# ^.*[ を [ にリプレース
perl -pe 's@^.*\[@[@g'
マッチパターン
perl -pe 's@^(\[.*\])\t(/.*/)@\2\t\1@g' |\
  • \1, \2で指定している。

3番目のフィールド値を出力

元の値
$ date
2015年 7月28日 火曜日 13時18分05秒 JST
awkでいうところのこれ
$ date | awk '{print $3}'
火曜日
perlだとこう
$ date | perl -ane 'print $F[2], "\n"'
火曜日

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