How to use the ls-l--time-style command to view a file is created on a weekday

Source: Internet
Author: User
Tags log

Viewing a file is a few of the ways that you create the week summarizes the following three methods:

1. Using the LS command to combine the grep method:

Ls-l--time-style ' +%a ' | Grep-e "tuesday| Wednesday "

2. Method of using awk 1:

[Oracle@bys3 ~]$ ls-l--time-style ' +%a ' |awk ' $6== ' Friday ' | | $6== "Tuesday" {print $} '

-rw-r--r--1 Oracle oinstall 253 Friday archback.sh

-rw-r--r--1 Oracle Oinstall 199 Friday bbedfile.txt

-RW-R-----1 Oracle oinstall 1958583 Friday BYS3_ORA_13020.TRC

-rw-r--r--1 Oracle Oinstall Tuesday delarch.sh

Drwxr-xr-x 3 Oracle Oinstall 4096 Tuesday Oradiag_oracle

[Oracle@bys3 ~]$

3. Using Awk Method 2:--It's a little complicated.

Declare-a Array

Array= (' ls-l--time-style ' +%a ' | awk ' {print $} ')

Echo ${array[0]}

length=${#array [@]}

Echo $length

For ((i=0;i< $length; i++))

Todo

Case ${array[$i]} in tuesday| Wednesday)

Ls-l--time-style ' +%a ' | Grep-e ${array[$i]}

Esac

Done

~

Examples of several usages of the 4.ls-l--time-style command:--You can write the commonly used environment variables as alias ls= '

See more highlights of this column: http://www.bianceng.cn/database/storage/

[Oracle@bys3 ~]$ ls-l--time-style= "+%y-%m-%d $newline%m-%d%h:%m"--shows the detailed date of year

Total 1964

-rw-r--r--1 Oracle Oinstall 17 2013-12-04 12-04 14:09 10

lrwxrwxrwx 1 Oracle oinstall 2013-12-01 12-01 22:53alert_bys3.log->/u01/diag/rdbms/bys3/bys3/trace/alert_bys3 . log

-rw-r--r--1 Oracle Oinstall 253 2013-11-15 11-15 21:25

[Oracle@bys3 ~]$ ls-l--time-style= "ISO"

Total 1964

-rw-r--r--1 Oracle Oinstall 17 12-04 14:09 10

lrwxrwxrwx 1 Oracle oinstall 12-01 22:53 alert_bys3.log->/u01/diag/rdbms/bys3/bys3/trace/alert_bys3.log

-rw-r--r--1 Oracle Oinstall 253 11-15 21:25 archback.sh

[Oracle@bys3 ~]$ ls-l--time-style= "+%b%e%y$newline%b%e%h:%m"

Total 1964

-rw-r--r--1 Oracle Oinstall-DEC 4 2013Dec 4 14:09 10

lrwxrwxrwx 1 Oracle Oinstall DEC 1 2013Dec 1 22:53alert_bys3.log->/u01/diag/rdbms/bys3/bys3/trace/alert_bys 3.log

-rw-r--r--1 Oracle Oinstall 253 Nov 2013Nov 21:25 archback.sh

[Oracle@bys3 ~]$ ls-l--time-style= "locale"

Total 1964

-rw-r--r--1 Oracle Oinstall DEC 4 14:09 10

lrwxrwxrwx 1 Oracle Oinstall DEC 1 22:53 alert_bys3.log->/u01/diag/rdbms/bys3/bys3/trace/alert_bys3.log

-rw-r--r--1 Oracle oinstall 253 Nov 21:25

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.