25

I found there are two files with same names but one with extended attribute while the other not (Actually I used sed command to do in-place operation with one file before):

-rw-r--r--  1 nanxiao  staff   351K Sep 28 12:29 db_chunks.csv
-rw-r--r--@ 1 nanxiao  staff   351K Sep 28 09:55 db_chunks.csv

So when I open db_chunks.csv, which file is actually operated? What is the relationship with these two files?

P.S., my macOS is Catalina.

Edit: The following is the output of ls -lb:

-rw-r--r--  1 nanxiao  staff  538150 Sep 28 12:29 pcap_chunks.csv
-rw-r--r--@ 1 nanxiao  staff  538658 Sep 28 12:25 pcap_chunks.csv

And although both are csv files, they are classified as different file formats in Finder: enter image description here

The "Get info" of both files: enter image description here

1
  • 2
    the -Q agrument for ls in unix (along with -b) should quote the filename so you can see exactly what it is Sep 29, 2020 at 20:38

1 Answer 1

48

You cannot have two files with the same name in the same folder.

If you look closely at the "Get Info" screenshots you've posted - there seems to be a much larger gap between the filename and "Info" on the left-most screenshot compared to the right-most screenshot.

This seems to indicate that you've probably have a space at the end of the name of one of the files. You can just rename the file in Finder to give it a separate name and remove the space.

5
  • 9
    which is underscored by the fact that Numbers only wants to open one of the files, the filetype of the other file it not "csv", but something different.
    – luk2302
    Sep 28, 2020 at 13:57
  • 2
    Also, if you select the text in the ls -lb codeblock, you'll notice a stray space.
    – AAM111
    Sep 29, 2020 at 2:07
  • 4
    Another way to see this from the command line is ls -lb | sed -nel. Those options to sed make it (among other things) add a dollar sign to the end of each line, so you'll have ... db_chunks.csv$ for one file, and ... db_chunks.csv $ for the other one.
    – zwol
    Sep 29, 2020 at 18:23
  • 1
    Or use the GNU tools (e.g. from homebrew): gls will produce abc 'abc '
    – jrw32982
    Sep 29, 2020 at 20:07
  • 2
    @OldBunny2800 The codeblock does not contain an extra space, you are probably selecting the enter character on the first line, but not on the second. Press Ctrl+a and see that both selection boxes have the same length
    – Ferrybig
    Sep 30, 2020 at 15:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .