zoukankan      html  css  js  c++  java
  • 文件操作符|-e|-M|-s|-A|_|-r -w $filename|stat|localtime|&|>>|<<

    TTY:终端是一种字符型设备,它有多种类型,通常使用tty 来简称各种类型的终端设备

     1 #!/usr/bin/perl
     2 
     3 use strict;
     4 use warnings;
     5 
     6 print "exist!
    " if -e '1.txt';
     7 print "exist!
    " if -e '2.txt';
     8 
     9 #exist!
    10 #
    11 
    12 warn "new file!
    " if -M '1.txt' < 2;
    13 
    14 #new file!
    15 
    16 my $filename = '1.txt';
    17 if((-s $filename <100_000) &&(-A _ < 1)){print "this file is small and new!
    ";}
    18 if(-w -r _ ){print "this file is both writable and readable!
    ";}
    19 
    20 #this file is small and new!
    21 #this file is both writable and readable!
    22 
    23 my $file = -s $filename;print "file size is $file"."B
    ";
    24 
    25 #file size is 116B
    26 
    27 if (-l 'check.pl'){print "check.pl is a file with link
    "}
    28 
    29 #check.pl is a file with link
    30 
    31 my $M = -M '1.txt';my $C = -C 'check.pl';my $A = -A 'check.pl';print "$M	$C	$A
    ";
    32 
    33 #0.0313657407407407407   3.10847222222222222     3.10847222222222222
    34 
    35 $_ ='1.txt';if (-r){print "$_ is a readhandle
    "}
    36 
    37 #1.txt is a readhandle
    38 
    39 my $size = (-s)/1024;print "$size
    ";
    40 
    41 #0.11328125
    42 
    43 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat('1.txt');$atime = localtime $atime;
    44 my ($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst)=localtime $ctime;
    45 print "dev_number=$dev
    inode =$ino
    mode=$mode
    hard link=$nlink
    user id=$uid
    group id=$gid
    $rdev
    size=$size
    $atime
    $mtime
    $ctime
    $blksize
    $blocks
    ";
    46 print "$yday
    ";
    47 
    48 #dev_number=43
    49 #inode =95085688861
    50 #mode=33188
    51 #hard link=1
    52 #user id=1000092
    53 #group id=30086
    54 #0
    55 #size=116
    56 #Sun Jun 30 17:17:20 2019
    57 #1561886240
    58 #1561886240
    59 #1048576
    60 #8
    61 #180
    62 
    63 my $now =gmtime;print "$now
    ";
    64 
    65 #Sun Jun 30 11:10:25 2019
    66 
    67 my $two = 12&2;print "$two
    ";
    68 my $move = 25.5>>2;print "$move
    ";
    69 $move = (25>>2)<<2;print "$move
    ";
    70 
    71 #0
    72 #6
    73 #24
  • 相关阅读:
    CH Dream(侠客行)
    EDS(特征)
    EDS(架构)
    通过红外线设备进行TCP/IP互连
    CH Dream(道路)
    北漂实习那些话【一】
    程序员,有时我们应该懂得
    迷茫的IT小小鸟
    《PHP求职宝典》PHP语言基础笔记
    Android中Activity启动模式详解
  • 原文地址:https://www.cnblogs.com/yuanjingnan/p/11110852.html
Copyright © 2011-2022 走看看