Skip to main content
The script for deleting extended attributes was too prominent (there is also xattr -c)
Source Link
Lri
  • 41.7k
  • 7
  • 123
  • 158

It's a product of extended file attributes. The file foo has anOS X's tar uses the AppleDouble format to store extended attribute, which you can see with ls -l:attributes and ACLs.

$ ls -l
...
-rw-r--r--@ 1 beder  staff touch file1 file2 file3
$ 760xattr Oct-w 26key 19:12value foofile1

The @ sign indicates that it has an extended attribute. To see what it is:

$ xattrchmod foo
com.apple.TextEncoding

tar recognizes the extended attribute and creates ._foo in the archive, which is then reconstructed when it's unpacked. So how to get rid of them? It's actually pretty annoying. For one file, it's easy:

$+a xattr'admin -dallow "com.apple.TextEncoding"delete' foofile2
$ ls -l
...le@ *
-rw-r--r-- @ 1 bederlauri  staff     7600 OctMay 2625 1907:12 foo

Presto! But for many files, it's more difficult. I used the following script to get rid of them, but it's pretty slow:

# /usr/bin/bash

dir=$1

rmvattr() {
    cd "$1"
    echo "Entering09 $1"file1
    for d in *
   key do5
        if [ -d "$d" ]; then
           rw-r--r--+ (rmvattr1 "$d")
lauri  staff  0 May 25 07:09 elsefile2
          0: group:admin enc=`xattrallow $d`delete
 -rw-r--r--  1 lauri  staff  if0 [$encMay !=25 ""];07:09 thenfile3
               $ xattrtar -dcf $enc1.tar $d*
         $ tar -tf fi1.tar
        fi./._file1
    donefile1
}./._file2
file2
(rmvattr $dir)file3

Unfortunately, there is no option for tarOS X's tar also knows how to ignore extended attributes (on Linux, it appears --no-xattrs works, but this doesn't exist on my version ofconvert the tar). One option is_ members back to copy everythingnative formats, and usebut the option cp -X, which ignores extended attributes. Another option, which I found from a couple threads, including here is_ files are usually kept when archives are extracted on other platforms. You can tell tar to setnot include the metadata by setting COPYFILE_DISABLE to some value:

export$ COPY_EXTENDED_ATTRIBUTES_DISABLE=trueCOPYFILE_DISABLE=1 tar -cf 2.tar file*    

on Tiger, or

export$ COPYFILE_DISABLE=truetar -tf 2.tar
file1
file2
file3
  • The copyfile functions are described in man copyfile
  • ls -l@ shows the keys and sizes of extended attributes, ls -le prints ACLs
  • xattr -l lists the keys and values of extended attributes
  • xattr -c clears all extended attributes (-d can't be used alone)
  • chmod -N deletes ACLs
  • Zip files created on OS X use a __MACOSX folder to store similar metadata

on Leopard and newer OS X. Then tar (and I think everything else) will ignore allInformation stored as extended attributes.:

  • Resource forks (resource forks have been extended attributes since 10.4)
    • Custom icons set in Finder and the images of Icon\r files
    • Metadata in PSD files
    • Objects stored in scpt files, AppleScript Editor window state, descriptions of scripts
  • Information about aliases (aliases stop working if extended attributes are removed)
  • Quarantine status or source URLs of files downloaded from the internet
  • Spotlight comments
  • Encoding of files saved with TextEdit
  • Caret position of files opened with TextMate
  • Skim notes

It's a product of extended file attributes. The file foo has an extended attribute, which you can see with ls -l:

$ ls -l
...
-rw-r--r--@ 1 beder  staff     760 Oct 26 19:12 foo

The @ sign indicates that it has an extended attribute. To see what it is:

$ xattr foo
com.apple.TextEncoding

tar recognizes the extended attribute and creates ._foo in the archive, which is then reconstructed when it's unpacked. So how to get rid of them? It's actually pretty annoying. For one file, it's easy:

$ xattr -d "com.apple.TextEncoding" foo
$ ls -l
...
-rw-r--r--  1 beder  staff     760 Oct 26 19:12 foo

Presto! But for many files, it's more difficult. I used the following script to get rid of them, but it's pretty slow:

# /usr/bin/bash

dir=$1

rmvattr() {
    cd "$1"
    echo "Entering $1"
    for d in *
    do
        if [ -d "$d" ]; then
            (rmvattr "$d")
        else
            enc=`xattr $d`
        if [$enc != ""]; then
                xattr -d $enc $d
            fi
        fi
    done
}

(rmvattr $dir)

Unfortunately, there is no option for tar to ignore extended attributes (on Linux, it appears --no-xattrs works, but this doesn't exist on my version of tar). One option is to copy everything, and use the option cp -X, which ignores extended attributes. Another option, which I found from a couple threads, including here is to set

export COPY_EXTENDED_ATTRIBUTES_DISABLE=true

on Tiger, or

export COPYFILE_DISABLE=true

on Leopard and newer OS X. Then tar (and I think everything else) will ignore all extended attributes.

OS X's tar uses the AppleDouble format to store extended attributes and ACLs.

$ touch file1 file2 file3
$ xattr -w key value file1
$ chmod +a 'admin allow delete' file2
$ ls -le@ *
-rw-r--r--@ 1 lauri  staff  0 May 25 07:09 file1
    key 5
-rw-r--r--+ 1 lauri  staff  0 May 25 07:09 file2
 0: group:admin allow delete
-rw-r--r--  1 lauri  staff  0 May 25 07:09 file3
$ tar -cf 1.tar *
$ tar -tf 1.tar
./._file1
file1
./._file2
file2
file3

OS X's tar also knows how to convert the ._ members back to native formats, but the ._ files are usually kept when archives are extracted on other platforms. You can tell tar to not include the metadata by setting COPYFILE_DISABLE to some value:

$ COPYFILE_DISABLE=1 tar -cf 2.tar file*    
$ tar -tf 2.tar
file1
file2
file3
  • The copyfile functions are described in man copyfile
  • ls -l@ shows the keys and sizes of extended attributes, ls -le prints ACLs
  • xattr -l lists the keys and values of extended attributes
  • xattr -c clears all extended attributes (-d can't be used alone)
  • chmod -N deletes ACLs
  • Zip files created on OS X use a __MACOSX folder to store similar metadata

Information stored as extended attributes:

  • Resource forks (resource forks have been extended attributes since 10.4)
    • Custom icons set in Finder and the images of Icon\r files
    • Metadata in PSD files
    • Objects stored in scpt files, AppleScript Editor window state, descriptions of scripts
  • Information about aliases (aliases stop working if extended attributes are removed)
  • Quarantine status or source URLs of files downloaded from the internet
  • Spotlight comments
  • Encoding of files saved with TextEdit
  • Caret position of files opened with TextMate
  • Skim notes

It's a product of extended file attributes. The file foo has an extended attribute, which you can see with ls -l:

$ ls -l
...
-rw-r--r--@ 1 beder  staff     760 Oct 26 19:12 foo

The @ sign indicates that it has an extended attribute. To see what it is:

$ xattr foo
com.apple.TextEncoding

tar recognizes the extended attribute and creates ._foo in the archive, which is then reconstructed when it's unpacked. So how to get rid of them? It's actually pretty annoying. For one file, it's easy:

$ xattr -d "com.apple.TextEncoding" foo
$ ls -l
...
-rw-r--r--  1 beder  staff     760 Oct 26 19:12 foo

Presto! But for many files, it's more difficult. I used the following script to get rid of them, but it's pretty slow:

# /usr/bin/bash

dir=$1

rmvattr() {
    cd "$1"
    echo "Entering $1"
    for d in *
    do
        if [ -d "$d" ]; then
            (rmvattr "$d")
        else
            enc=`xattr $d`
        if [$enc != ""]; then
                xattr -d $enc $d
            fi
        fi
    done
}

(rmvattr $dir)

Unfortunately, there is no option for tar to ignore extended attributes (on Linux, it appears --no-xattrs works, but this doesn't exist on my version of tar). One option is to copy everything, and use the option cp -X, which ignores extended attributes. Another option, which I found from a couple threads, including here is to set

export COPY_EXTENDED_ATTRIBUTES_DISABLE=true

on Tiger, or

export COPYFILE_DISABLE=true

on Leopard, Snow Leopard, and Lionnewer OS X. Then tar (and I think everything else) will ignore all extended attributes.

It's a product of extended file attributes. The file foo has an extended attribute, which you can see with ls -l:

$ ls -l
...
-rw-r--r--@ 1 beder  staff     760 Oct 26 19:12 foo

The @ sign indicates that it has an extended attribute. To see what it is:

$ xattr foo
com.apple.TextEncoding

tar recognizes the extended attribute and creates ._foo in the archive, which is then reconstructed when it's unpacked. So how to get rid of them? It's actually pretty annoying. For one file, it's easy:

$ xattr -d "com.apple.TextEncoding" foo
$ ls -l
...
-rw-r--r--  1 beder  staff     760 Oct 26 19:12 foo

Presto! But for many files, it's more difficult. I used the following script to get rid of them, but it's pretty slow:

# /usr/bin/bash

dir=$1

rmvattr() {
    cd "$1"
    echo "Entering $1"
    for d in *
    do
        if [ -d "$d" ]; then
            (rmvattr "$d")
        else
            enc=`xattr $d`
        if [$enc != ""]; then
                xattr -d $enc $d
            fi
        fi
    done
}

(rmvattr $dir)

Unfortunately, there is no option for tar to ignore extended attributes (on Linux, it appears --no-xattrs works, but this doesn't exist on my version of tar). One option is to copy everything, and use the option cp -X, which ignores extended attributes. Another option, which I found from a couple threads, including here is to set

export COPY_EXTENDED_ATTRIBUTES_DISABLE=true

on Tiger, or

export COPYFILE_DISABLE=true

on Leopard, Snow Leopard, and Lion. Then tar (and I think everything else) will ignore all extended attributes.

It's a product of extended file attributes. The file foo has an extended attribute, which you can see with ls -l:

$ ls -l
...
-rw-r--r--@ 1 beder  staff     760 Oct 26 19:12 foo

The @ sign indicates that it has an extended attribute. To see what it is:

$ xattr foo
com.apple.TextEncoding

tar recognizes the extended attribute and creates ._foo in the archive, which is then reconstructed when it's unpacked. So how to get rid of them? It's actually pretty annoying. For one file, it's easy:

$ xattr -d "com.apple.TextEncoding" foo
$ ls -l
...
-rw-r--r--  1 beder  staff     760 Oct 26 19:12 foo

Presto! But for many files, it's more difficult. I used the following script to get rid of them, but it's pretty slow:

# /usr/bin/bash

dir=$1

rmvattr() {
    cd "$1"
    echo "Entering $1"
    for d in *
    do
        if [ -d "$d" ]; then
            (rmvattr "$d")
        else
            enc=`xattr $d`
        if [$enc != ""]; then
                xattr -d $enc $d
            fi
        fi
    done
}

(rmvattr $dir)

Unfortunately, there is no option for tar to ignore extended attributes (on Linux, it appears --no-xattrs works, but this doesn't exist on my version of tar). One option is to copy everything, and use the option cp -X, which ignores extended attributes. Another option, which I found from a couple threads, including here is to set

export COPY_EXTENDED_ATTRIBUTES_DISABLE=true

on Tiger, or

export COPYFILE_DISABLE=true

on Leopard and newer OS X. Then tar (and I think everything else) will ignore all extended attributes.

added 24 characters in body
Source Link
Jesse Beder
  • 1.8k
  • 1
  • 13
  • 14

It's a product of extended file attributes. The file foo has an extended attribute, which you can see with ls -l:

$ ls -l
...
-rw-r--r--@ 1 beder  staff     760 Oct 26 19:12 foo

The @ sign indicates that it has an extended attribute. To see what it is:

$ xattr foo
com.apple.TextEncoding

tar recognizes the extended attribute and creates ._foo in the archive, which is then reconstructed when it's unpacked. So how to get rid of them? It's actually pretty annoying. For one file, it's easy:

$ xattr -d "com.apple.TextEncoding" foo
$ ls -l
...
-rw-r--r--  1 beder  staff     760 Oct 26 19:12 foo

Presto! But for many files, it's more difficult. I used the following script to get rid of them, but it's pretty slow:

# /usr/bin/bash

dir=$1

rmvattr() {
    cd "$1"
    echo "Entering $1"
    for d in *
    do
        if [ -d "$d" ]; then
            (rmvattr "$d")
        else
            enc=`xattr $d`
        if [$enc != ""]; then
                xattr -d $enc $d
            fi
        fi
    done
}

(rmvattr $dir)

Unfortunately, there is no option for tar to ignore extended attributes (on Linux, it appears --no-xattrs works, but this doesn't exist on my version of tar). One option is to copy everything, and use the option cp -X, which ignores extended attributes. Another option, which I found from a couple threads, including here is to set

export COPY_EXTENDED_ATTRIBUTES_DISABLE=true

on Tiger, or

export COPYFILE_DISABLE=true

on Leopard, Snow Leopard, and Lion. Then tar (and I think everything else) will ignore all extended attributes.

It's a product of extended file attributes. The file foo has an extended attribute, which you can see with ls -l:

$ ls -l
...
-rw-r--r--@ 1 beder  staff     760 Oct 26 19:12 foo

The @ sign indicates that it has an extended attribute. To see what it is:

$ xattr foo
com.apple.TextEncoding

tar recognizes the extended attribute and creates ._foo in the archive, which is then reconstructed when it's unpacked. So how to get rid of them? It's actually pretty annoying. For one file, it's easy:

$ xattr -d "com.apple.TextEncoding" foo
$ ls -l
...
-rw-r--r--  1 beder  staff     760 Oct 26 19:12 foo

Presto! But for many files, it's more difficult. I used the following script to get rid of them, but it's pretty slow:

# /usr/bin/bash

dir=$1

rmvattr() {
    cd "$1"
    echo "Entering $1"
    for d in *
    do
        if [ -d "$d" ]; then
            (rmvattr "$d")
        else
            enc=`xattr $d`
        if [$enc != ""]; then
                xattr -d $enc $d
            fi
        fi
    done
}

(rmvattr $dir)

Unfortunately, there is no option for tar to ignore extended attributes (on Linux, it appears --no-xattrs works, but this doesn't exist on my version of tar). One option is to copy everything, and use the option cp -X, which ignores extended attributes. Another option, which I found from a couple threads, including here is to set

export COPY_EXTENDED_ATTRIBUTES_DISABLE=true

on Tiger, or

export COPYFILE_DISABLE=true

on Leopard. Then tar (and I think everything else) will ignore all extended attributes.

It's a product of extended file attributes. The file foo has an extended attribute, which you can see with ls -l:

$ ls -l
...
-rw-r--r--@ 1 beder  staff     760 Oct 26 19:12 foo

The @ sign indicates that it has an extended attribute. To see what it is:

$ xattr foo
com.apple.TextEncoding

tar recognizes the extended attribute and creates ._foo in the archive, which is then reconstructed when it's unpacked. So how to get rid of them? It's actually pretty annoying. For one file, it's easy:

$ xattr -d "com.apple.TextEncoding" foo
$ ls -l
...
-rw-r--r--  1 beder  staff     760 Oct 26 19:12 foo

Presto! But for many files, it's more difficult. I used the following script to get rid of them, but it's pretty slow:

# /usr/bin/bash

dir=$1

rmvattr() {
    cd "$1"
    echo "Entering $1"
    for d in *
    do
        if [ -d "$d" ]; then
            (rmvattr "$d")
        else
            enc=`xattr $d`
        if [$enc != ""]; then
                xattr -d $enc $d
            fi
        fi
    done
}

(rmvattr $dir)

Unfortunately, there is no option for tar to ignore extended attributes (on Linux, it appears --no-xattrs works, but this doesn't exist on my version of tar). One option is to copy everything, and use the option cp -X, which ignores extended attributes. Another option, which I found from a couple threads, including here is to set

export COPY_EXTENDED_ATTRIBUTES_DISABLE=true

on Tiger, or

export COPYFILE_DISABLE=true

on Leopard, Snow Leopard, and Lion. Then tar (and I think everything else) will ignore all extended attributes.

edited body
Source Link
Jesse Beder
  • 1.8k
  • 1
  • 13
  • 14
Loading
Source Link
Jesse Beder
  • 1.8k
  • 1
  • 13
  • 14
Loading