1

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?

7

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
    
  • @nohillside I can’t reproduce -i overriding multi-column, do you have an ls alias or something? I’ve tested on Mojave. – grg Dec 19 '18 at 18:43
  • Interesting. I get one-column output even when running ` \ls -axi`. – nohillside Dec 19 '18 at 18:46
  • Nevertheless, rolled back. – nohillside Dec 19 '18 at 18:46
  • Ah, depends on terminal width (and max length of application name). If I fullscreen Terminal I get multi-column as well. – nohillside Dec 19 '18 at 18:47
  • @nohillside How wide is your Terminal window and the length of the lines you’re trying to print? ls -xi ~ if you just have the default folders in your home folder, they’re quite short and show in columns for me. I’ll add some output myself. – grg Dec 19 '18 at 18:47
-1

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

The backslash is an escape. Take the next character literally. So, It seems you type ls -a\ then pressed return which gives you the prompt. You must have then typed xi. The history command doesn't remember the line continuation sequence, so you get ls -axi

My experimentation with \

mac $ touch hi\"there\"
mac $ ls
containsBill  containsBob   containsJoe   hi"there"
mac $ ls -la hi\"there\" 
-rw-r--r--  1 mac  staff     0B Dec 19 19:56 hi"there"
mac $ ls -la\
>  hi\"there\" 
-rw-r--r--  1 mac  staff     0B Dec 19 19:56 hi"there" 
mac $ # press up arrow to get the previous command
mac $ ls -la hi\"there\" 
-rw-r--r--  1 mac  staff     0B Dec 19 19:56 hi"there"
mac $ ls -\a\l
total 40
drwxr-xr-x    7 mac  staff   238B Dec 19 19:56 ./
drwxr-xr-x+ 143 mac  staff   4.7K Dec 16 19:32 ../
-rw-r--r--@   1 mac  staff   6.0K Dec 19 15:05 .DS_Store
-rw-r--r--@   1 mac  staff    56B Dec 19 15:11 containsBill
-rw-r--r--    1 mac  staff     4B Dec 19 15:07 containsBob
-rw-r--r--    1 mac  staff     5B Dec 19 15:08 containsJoe
-rw-r--r--    1 mac  staff     0B Dec 19 19:56 hi"there"
mac $ # press up arrow to get the previous command
mac $ ls -\a\l

You must log in to answer this question.

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