2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

使っている sed コマンドが GNU版 か BSD版 か確認する方法

Posted at

コマンドに聞く

# GNU版~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 1. --version してみる
$ sed --version
sed (GNU sed) 4.4 # <<<<<<<<<<<<<<<<<<<<<<<<<< ここにGNUって書いてある
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed@gnu.org>.

# 2. 改行コードで終わっていない場合をみてみる
$ printf 'Hello,\nworld!' | sed ''
Hello,
world!$ # <<<<<<<<<<<<<<<<< 改行してくれない

# BSD版~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 1. --version してみる
$ sed --version # <<<<<<<<<<<<<< --versionってオプションがないから怒られる
sed: illegal option -- -
usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]

# 2. 改行コードで終わっていない場合をみてみる
$ printf 'Hello,\nworld!' | sed ''
Hello,
world!
$ # <<<<<<<<<<<<<<< 自動で改行してくれる

# 3. manに聞いてみる(微妙・・・)
$ man sed
# --manの表示--------------------------------------------------------------------------------
SED(1)                    BSD General Commands Manual                   SED(1)# <<<<<<<<<<<<<<< ここにBSDって書いてある

NAME
     sed -- stream editor

SYNOPSIS
<省略>

OSで推測する

sed OS
GNU版 Windows(GitBash for Windows)
BSD版 Mac

ほかは不明

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?