Ls usage

From raju

Show file date in YYYY-MM-DD format

Use --time-style='+%Y-%m-%d'

    % ls -l --time-style='+%Y-%m-%d' ~/.vimrc
    -rwx------ 1 rajulocal rajulocal 1087 2020-04-27 /home/rajulocal/.vimrc*
    % ls -l ~/.vimrc
    -rwx------ 1 rajulocal rajulocal 1087 Apr 27 20:56 /home/rajulocal/.vimrc*


"ls -F" appends indicators */=>@| to filenames.

  • * means executable.
  • / means directory.
  • = means socket.
  • > means door.
  • @ means symbolic link (or that the file has extended attributes).
  • | means named pipe.


only show filename and modification time

    ls -al | cut -d ' ' -f 6- 

Another way (using find):

    find -maxdepth 1 -type f -printf "%TY %Tb %Td %TH:%TM\t%p\n"

To sort the files based on timestamp (reverse chronological order)

    find -maxdepth 1 -type f -printf "%T+#%TY %Tb %Td %TH:%TM\t%p\n" | sort -rn| cut -d# -f2-

The %T+ is used to sort the output properly and gets removed by cut afterwards.