Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown   Email 



TWEAK THE COMMAND "ls -l"


Sure, we all know the command "ls -l" . . . but that we can adapt the command to change the date & time output is something Doryforos will try to explain to us:

QUOTE (Doryforos @ Forum 2004)

Normally, ls outputs the modification date & time of files & folders
in the following (locale-dependent) format:

$ ls -l /etc/profile.d
total 84
-rwxr-xr-x 1 root root 790 Jun 1 10:26 colorls.csh
-rwxr-xr-x 1 root root 785 Jun 1 10:24 colorls.sh
...

i.e., ls outputs the date & time in the format:
"Month Day Modification_Time", when the modification time is recent, and in the format:
"Month Day Year", when the time is further in the past.

By issuing "ls -l --time-style=long-iso" at the command line, the
date & time output changes to a ISO standard format (in any case, users are given the choice...):

$ ls -l --time-style=long-iso /etc/profile.d
total 84
-rwxr-xr-x 1 root root 790 2004-06-01 10:26 colorls.csh
-rwxr-xr-x 1 root root 785 2004-06-01 10:24 colorls.sh
...

To have ls use this format permanently, in Fedora Core 2, edit the
files shown in the example output, adding "--time-style=long-iso"
at the lines beginning with "alias ll=" (and -- optionally -- at
the lines beginning with "alias ls="), as follows:

CODE

[colorls.sh, for bash]
if ! egrep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null; then
alias ll='ls -l --color=tty --time-style=long-iso' 2>/dev/null
alias l.='ls -d .* --color=tty' 2>/dev/null
alias ls='ls --color=tty --time-style=long-iso' 2>/dev/null
else
alias ll='ls -l --time-style=long-iso' 2>/dev/null
alias l.='ls -d .*' 2>/dev/null
fi




Thanks to Doryforos


Bruno


-- Jun 23 2004 ( Revised Dec 10 2005 ) --


Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown   Email