Subscribed unsubscribe Subscribe Subscribe

F# Monkey

about

grep 色情報はいらない〜 はまった〜

Summary

grepで文字列を取り出す時

色情報がついてて

sedしにくかった

Environment

$ sw_vers 
ProductName:    Mac OS X
ProductVersion: 10.12.4
BuildVersion:   16E195


$ uname -v
Darwin Kernel Version 16.5.0:
Fri Mar  3 16:52:33 PST 2017;
root:xnu-3789.51.2~3/RELEASE_X86_64

こんな感じ

cat ./abc.txt | grep -e '#r'
^[[01;31m^[[K#r^[[m^[[K @"./packages/FSharp.Control.Reactive/lib/net45/FSharp.Control.Reactive.dll"
^[[01;31m^[[K#r^[[m^[[K @"./packages/FSharp.Compiler.Service/lib/net45/FSharp.Compiler.Service.dll"
^[[01;31m^[[K#r^[[m^[[K @"./packages/Newtonsoft.Json/lib/net45/Newtonsoft.Json.dll"
^[[01;31m^[[K#r^[[m^[[K @"./packages/FsPickler/lib/net45/FsPickler.dll"
^[[01;31m^[[K#r^[[m^[[K @"./packages/FsPickler.Json/lib/net45/FsPickler.Json.dll"
^[[01;31m^[[K#r^[[m^[[K @"./packages/Suave/lib/net40/Suave.dll"

対策〜

cat ./abc.txt | grep --color=never -e '#r'
#r @"./packages/FSharp.Control.Reactive/lib/net45/FSharp.Control.Reactive.dll"
#r @"./packages/FSharp.Compiler.Service/lib/net45/FSharp.Compiler.Service.dll"
#r @"./packages/Newtonsoft.Json/lib/net45/Newtonsoft.Json.dll"
#r @"./packages/FsPickler/lib/net45/FsPickler.dll"
#r @"./packages/FsPickler.Json/lib/net45/FsPickler.Json.dll"
#r @"./packages/Suave/lib/net40/Suave.dll"
Remove all ads