LoginSignup
27
20

More than 5 years have passed since last update.

ダウンロードしたファイルを ls したときの @ マークを消す

Last updated at Posted at 2014-04-18

.app ファイルとかなら、一度 GUI 上で実行すると「ダウンロードしたファイルだけど本当に実行するかい?」ってダイアログが出て了解するとこのマークは消えるんだけど、ダウンロードしたものをコマンドラインから実行ができないとかいうときに困ることになる。

そもそも何なのかとか、以下を参考にした。

Mac OS X Tiger で導入された EA(Extended Attributes)というファイルのメタ情報が付いていると表示されるらしい。
xattr コマンドでどんな EA が付いてるかを見たり、消したりの操作ができる。

$ ls -la hoge.file
-rm-r--r--@  1 tmd45 staff   32 11 27 20:56 hoge.file

# 属性を確認
$ xattr hoge.file
com.apple.quarantine
# 属性を削除
$ xattr -d com.apple.quarantine hoge.file

$ ls -la hoge.file
-rm-r--r--   1 tmd45 staff   32 11 27 20:56 hoge.file

参考記事では xattr のマニュアルが無いとなっていたけど、いまは有る様子で man xattr で情報も見れる(長いので割愛)。 "display and manipulate extended attributes" コマンドらしい。

xattrコマンドのヘルプ
$ xattr -h
usage: xattr [-l] [-r] [-s] [-v] [-x] file [file ...]
       xattr -p [-l] [-r] [-s] [-v] [-x] attr_name file [file ...]
       xattr -w [-r] [-s] [-x] attr_name attr_value file [file ...]
       xattr -d [-r] [-s] attr_name file [file ...]
       xattr -c [-r] [-s] file [file ...]

The first form lists the names of all xattrs on the given file(s).
The second form (-p) prints the value of the xattr attr_name.
The third form (-w) sets the value of the xattr attr_name to the string attr_value.
The fourth form (-d) deletes the xattr attr_name.
The fifth form (-c) deletes (clears) all xattrs.

options:
  -h: print this help
  -l: print long format (attr_name: attr_value and hex output has offsets and
      ascii representation)
  -r: act recursively
  -s: act on the symbolic link itself rather than what the link points to
  -v: also print filename (automatic with -r and with multiple files)
  -x: attr_value is represented as a hex string for input and output

デフォルトでこれを付かなくする設定とか無いのかな?
セキュリティに関わる部分っぽいし一律 OFF にするのもいかがなものかとも思うけど。

27
20
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
27
20