Linuxには、次の内容を含むテキストファイルがあります。
help.helloworld.com:latest.world.com
dev.helloworld.com:latest.world.com
次のようにコロンの前に内容をインポートしたいと思います。
help.helloworld.com
dev.helloworld.com
端末内でこれをどのように実行できますか?
ベストアンサー1
これは以下のcut
ためのものです:
$ cat file
help.helloworld.com:latest.world.com
dev.helloworld.com:latest.world.com
foo:baz:bar
foo
$ cut -d: -f1 file
help.helloworld.com
dev.helloworld.com
foo
foo
区切り文字を:
withに設定し-d:
て最初のフィールド(-f1
)のみを印刷するように指示するだけです。