MacOS Terminal – What Does ‘ls -axi’ Command Do?

bashmacosterminal

So I was messing around in terminal, and when i opened it, I typed cd applications .

Nothing bad here.

Then, I typed ls -a\ in applications (or maybe /, I don't know, but it opened the > thing after for a multi line command.

Not remembering how to exit, I tried to type exit but instead typed xi and hit enter on my MAcBook Air. It said that it was doing something, but i tried to quit the terminal seeing it was deleting/restoring something (pls don't question my logic here).

Have no idea what it did, but when i go up in terminal, it says i typed ls -axi

What did this do?

Best Answer

ls -axi would have performed a regular directory listing, but with more contents (-a showing dot-files), a horizontal sort (-x) in columns, and with the inode number present (-i).

From the man page for ls:

  • -a

    Include directory entries whose names begin with a dot (.).

    ~ $ ls
    Desktop     Downloads  Movies  Pictures
    Documents   Library    Music   Public
    
    ~ $ ls -a
    .          Downloads  Pictures
    ..         Library    Public
    Desktop    Movies
    Documents  Music
    
  • -x

    The same as -C, except that the multi-column output is produced with entries sorted across, rather than down, the columns.

    • -C

      Force multi-column output; this is the default when output is to a terminal.

    ~ $ ls -ax
    .          ..         Desktop
    Documents  Downloads  Library
    Movies     Music      Pictures
    Public
    
  • -i

    For each file, print the file's file serial number (inode number).

    ~ $ ls -axi
    686312 .          643912 ..         686338 Desktop
    686325 Documents  686327 Downloads  686313 Library
    686390 Movies     686333 Music      686336 Pictures
    686386 Public