zoukankan      html  css  js  c++  java
  • Solaris下怎样改动文件创建时间及查询

    Solaris下怎样改动文件创建时间及查询


    实验演示:


    1、核对时间

    [root@S1011:/]# date
    Tue Jul 15 21:37:01 CDT 2014

    --若时间不对请先按例如以下格式改动
    [root@S1011:/]# date 0715221114            --2014年7月15日22:11
    Tue Jul 15 22:11:00 CDT 2014


    2、创建实验环境

    [root@S1011:/]# mkdir test

    [root@S1011:/]# cd test

    [root@S1011:/test]# touch test1
    [root@S1011:/test]# touch test2
    [root@S1011:/test]# mkdir dirtest1
    [root@S1011:/test]# mkdir dirtest2
    [root@S1011:/test]# ls
    dirtest1  dirtest2  test1     test2

    3、查询文件创建时间

    --此次查询,显示出了详细的创建时间点

    [root@S1011:/test]# ls -ll
    total 8
    drwxr-xr-x   2 root     root           2 Jul 15 22:30 dirtest1
    drwxr-xr-x   2 root     root           2 Jul 15 22:30 dirtest2
    -rw-r--r--   1 root     root           0 Jul 15 22:30 test1
    -rw-r--r--   1 root     root           0 Jul 15 22:30 test2

    补充:

    --这里要注意一点,在UNIX系统下,我们查看创建时间时,假设超过了半年以上就仅仅显示年份,不显示详细时间,例如以下

    [root@S1011:/]# ls -ll
    total 1063
    drwxr-xr-x   2 root     root           2 Feb 19 12:12 123
    lrwxrwxrwx   1 root     root           9 Apr 24  2013 bin -> ./usr/bin
    drwxr-xr-x   8 root     sys           11 Apr 24  2013 boot
    drwxr-xr-x   3 root     nobody         4 Apr 24  2013 cdrom
    drwxr-xr-x   2 root     root           3 Feb 19 12:32 Desktop
    drwxr-xr-x  19 root     sys          372 Jul 15 15:22 dev
    drwxr-xr-x   4 root     sys           12 Jul 15 15:22 devices
    drwxr-xr-x   2 root     root           2 Apr 24  2013 Documents
    drwxr-xr-x  88 root     sys          244 Jul 15 15:22 etc
    drwxr-xr-x   2 root     root           2 Feb 14 17:58 exercise
    drwxr-xr-x   3 root     sys            3 Apr 24  2013 export
    dr-xr-xr-x   1 root     root           1 Jul 15 15:22 home
    drwxr-xr-x  18 root     sys           19 Apr 24  2013 kernel
    drwxr-xr-x   8 root     bin          243 Apr 24  2013 lib
    drwxr-xr-x   2 root     sys            2 Apr 24  2013 mnt
    dr-xr-xr-x   1 root     root           1 Jul 15 15:22 net
    drwxr-xr-x   5 root     sys            5 Apr 25  2013 opt
    drwxr-xr-x   5 root     sys            5 Apr 24  2013 platform
    dr-xr-xr-x  91 root     root      480032 Jul 15 22:37 proc
    -rw-r--r--   1 root     root          32 Apr 24  2013 profile
    drwxr-xr-x   4 root     root           4 Apr 24  2013 rpool
    drwxr-xr-x   2 root     sys           54 Apr 24  2013 sbin
    drwxrwxr-x   3 oracle   oinstall       3 Feb 18 19:50 spool
    drwxr-xr-x   4 root     root           4 Apr 24  2013 system
    drwxr-xr-x   4 root     root           6 Jul 15 22:30 test
    drwxrwxrwt   6 root     sys          532 Jul 15 15:22 tmp
    drwxrwxr-x   3 root     root           3 Apr 24  2013 u01
    drwxr-xr-x   3 root     root           3 Apr 24  2013 u02
    drwxr-xr-x  42 root     sys           56 Apr 25  2013 usr
    drwxr-xr-x  44 root     sys           44 Apr 24  2013 var
    dr-xr-xr-x   6 root     root         512 Jul 15 15:22 vol


    4、改动文件夹、文件的创建时间

    [root@S1011:/test]# ls -ll|grep dirtest1                                           --查看文件夹创建时间
    drwxr-xr-x   2 root     root           2 Jul 15 22:30 dirtest1

    [root@S1011:/test]# touch -t 200711011200.00 dirtest1--改动文件夹的创建时间为:2007年11月1日12:00
    [root@S1011:/test]# ls -ll|grep dirtest1 --查看文件夹改动后的创建时间,因为创建时间超过半年,仅仅显示年份
    drwxr-xr-x   2 root     root           2 Nov  1  2007 dirtest1


    [root@S1011:/test]# ls -atl test1              --查看文件创建时间
    -rw-r--r--   1 root     root           0 Jul 15 22:30 test1

    [root@S1011:/]# touch -t 201406121200.00 test1--改动文件的创建时间为:2014年6月12日12:00
    [root@S1011:/]# ls -alt test1--查看文件改动后的时间为,6月12日12:00,能够表明之前改动的文件创建时间生效了
    -rw-r--r--   1 root     root           0 Jun 12 12:00 test1


    5、小结

    1、对于创建时间的改动,使用touch命令,另其他关于touch命令使用方法能够运行“# man touch”查看;

    2、在unix系统中超过半年的文件,查询时仅仅显示年份。


    ***********************************************声明************************************************ 

    原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明出处(http://blog.csdn.net/huangyanlong)。

    表述有错误之处,请您留言,不胜感激。

    提醒:点击文件夹,更有助于您的查看。

    *****************************************************************************************************



































  • 相关阅读:
    基本的数据库操作类
    GridView 导出Excle
    VS2005 调试时断点无效的小问题
    TSQL日期相关
    Data Access Application Block 利用DataSet 操作DB
    vs2005 字体和颜色加载包失败,无法修改的问题
    GridView 编辑和删除的实现
    operamasksui之omGrid简单使用
    ANT简明教程
    ANT从入门到精通
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/4059220.html
Copyright © 2011-2022 走看看