Pages

Thursday, June 29, 2017

7 Quirky ‘ls’ Command Tricks Every Linux User Should Know

We have covered most of the things on ‘ls’ command in last two articles of our Interview series. This article is the last part of the ‘ls command‘ series. If you have not gone through last two articles of this series you may visit the links below.
  1. 15 Basic ‘ls’ Command Examples in Linux
  2. Sort Output of ‘ls’ Command By Last Modified Date and Time
  3. 15 Interview Questions on Linux “ls” Command – Part 1
  4. 10 Useful ‘ls’ Command Interview Questions – Part 2
ls command tricks
7 Quirky ls Command Tricks
1. List the contents of a directory with time using various time styles.
To list the contents of a directory with times using style, we need to choose any of the below two methods.
# ls -l –time-style=[STYLE]               (Method A)
Note – The above switch (--time style must be run with switch -l, else it won’t serve the purpose).
# ls –full-time                           (Method B)
Replace [STYLE] with any of the below option.
full-iso
long-iso
iso
locale
+%H:%M:%S:%D
Note – In the above line H(Hour), M(Minute), S(Second), D(Date) can be used in any order.
Moreover you just choose those relevant and not all options. E.g., ls -l --time-style=+%H will show only hour.
ls -l --time-style=+%H:%M:%D will show Hour, Minute and date.
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
                                                    ► Read more: http://adf.ly/1nBXu1
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

No comments:

Post a Comment