bash_action

通过进程号进入工作目录

使用pwdx命令,这是最简单的方法,提供进程号,该命令就可以返回进程的工作目录。

 

pwdx 13128
13128: /home/image/tianyi_to_biz

 

pwdx 13128 | awk '{print $2}'
/home/image/tianyi_to_biz

 

 

 

获取指定列  进程号

 

 ps -ef | grep Web | grep -v grep | awk '{print $2}' |xargs kill -9;ps -ef | grep Web | grep -v grep

 

 

#!/system/bin/sh
i=1;
while true
do
    echo `date "+%Y-%m-%d %H:%M:%S"`
    sleep 1s
    echo "Current Number: $((i++))"
done
 
    sleep 1s  可以改为     sleep 1
 
窗口无限输出 窗口保活

#!/bin/bash  
i=1;  
for (( ; ; ))  
do  
echo `date "+%Y-%m-%d %H:%M:%S"`
sleep 1s  
echo "Current Number: $((i++))"  
done

go执行sh
   cmd := exec.Command("/bin/sh", "/home/ftptest/testsh.sh")
        cmd.Dir = "/home/ftptest/code/CICD"
        _, err := cmd.Output()
#!/bin/bash
cd /home/ftptest/;mkdir t;mv t t123;cd t123;echo asd >123.txt;


 

实践

D:\>go build -o dev.exe && .\dev.exe --conf=D:\APP-2.0+3.0 --opensvc=false
&& 命令连接

 .\a.bat && .\b.bat

 

 

a@a:~/learn$ cat a.test
a a1 190
z a2 1
x a3 14
e a4 15
a@a:~/learn$ cat a.test | sort -dk 1
a a1 190
e a4 15
x a3 14
z a2 1
a@a:~/learn$ cat a.test | sort -nk 3
z a2 1
x a3 14
e a4 15
a a1 190
a@a:~/learn$
 
 sort --help
Usage: sort [OPTION]... [FILE]...
  or:  sort [OPTION]... --files0-from=F
Write sorted concatenation of all FILE(s) to standard output.

With no FILE, or when FILE is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
Ordering options:

  -b, --ignore-leading-blanks  ignore leading blanks
  -d, --dictionary-order      consider only blanks and alphanumeric characters
  -f, --ignore-case           fold lower case to upper case characters
  -g, --general-numeric-sort  compare according to general numerical value
  -i, --ignore-nonprinting    consider only printable characters
  -M, --month-sort            compare (unknown) < 'JAN' < ... < 'DEC'
  -h, --human-numeric-sort    compare human readable numbers (e.g., 2K 1G)
  -n, --numeric-sort          compare according to string numerical value
  -R, --random-sort           shuffle, but group identical keys.  See shuf(1)
      --random-source=FILE    get random bytes from FILE
  -r, --reverse               reverse the result of comparisons
      --sort=WORD             sort according to WORD:
                                general-numeric -g, human-numeric -h, month -M,
                                numeric -n, random -R, version -V
  -V, --version-sort          natural sort of (version) numbers within text

Other options:

      --batch-size=NMERGE   merge at most NMERGE inputs at once;
                            for more use temp files
  -c, --check, --check=diagnose-first  check for sorted input; do not sort
  -C, --check=quiet, --check=silent  like -c, but do not report first bad line
      --compress-program=PROG  compress temporaries with PROG;
                              decompress them with PROG -d
      --debug               annotate the part of the line used to sort,
                              and warn about questionable usage to stderr
      --files0-from=F       read input from the files specified by
                            NUL-terminated names in file F;
                            If F is - then read names from standard input
  -k, --key=KEYDEF          sort via a key; KEYDEF gives location and type
  -m, --merge               merge already sorted files; do not sort
  -o, --output=FILE         write result to FILE instead of standard output
  -s, --stable              stabilize sort by disabling last-resort comparison
  -S, --buffer-size=SIZE    use SIZE for main memory buffer
  -t, --field-separator=SEP  use SEP instead of non-blank to blank transition
  -T, --temporary-directory=DIR  use DIR for temporaries, not $TMPDIR or /tmp;
                              multiple options specify multiple directories
      --parallel=N          change the number of sorts run concurrently to N
  -u, --unique              with -c, check for strict ordering;
                              without -c, output only the first of an equal run
  -z, --zero-terminated     line delimiter is NUL, not newline
      --help     display this help and exit
      --version  output version information and exit

  

 

排序  sort  第6列按数字排序 : sort -nk 6

 

 

在系统所有文件中找出 含有"19.68.11"但不在log中的文件
sudo grep -rn "19.68.11" / | grep -v log

 

 

文本检索 全文检索 跨目录

sudo grep -r "12.18.1.18"

 

 

 

yarn 打日志 

kill -9

 

#/bin/bash
#输出 年-月-日
today=`date +%Y-%m-%d`

echo $today
my_array=( 'a' 'b' 'c' )
# 'ssh {} "scp /data/visitlog/{} root@d:/data/mapReduceVisitorLog/{}/"'
# 遍历数组
for i in ${my_array[*]}
do
echo $i
s="ssh ${i} 'scp /data/visitlog/*${today} root@d:/data/mapReduceVisitorLog/${i}/'"
echo $s
eval $s
s="ssh ${i} 'scp /data/unionlog/*${today} root@d:/data/mapReduceYunMengLog/${i}/'"
echo $s
eval $s
done



shell 处理时间

$ date
Thu Jan 21 11:43:00 CST 2016

(1) 获取当前时间

$ date +%Y-%m-%d
2016-01-27

$ date "+%Y-%m-%d %H:%M:%S"
2016-01-27 17:37:31

(2) 一年中的第几天,第几周,一周中的第几天。。。

$ date +%j #一年中的第几天
027

$ date +%d #一个月中的第几天
27
 
$ date +%w #一周中的第几天(0(周日) --> 6(周六))
3

$ date +%U #一年中的第几周
04

(3) 前后时间,加ago就是前,没有ago就是后

$date -d '1 years ago' "+%Y-%m-%d %H:%M:%S"
2015-01-27 17:54:39

$date -d '1 months ago' "+%Y-%m-%d %H:%M:%S"
2015-12-27 17:54:45

$ date -d '1 days ago' "+%Y-%m-%d %H:%M:%S"
2016-01-26 17:51:45

$date -d '1 hours ago' "+%Y-%m-%d %H:%M:%S"
2016-01-27 16:52:29

$date -d '1 minutes ago' "+%Y-%m-%d %H:%M:%S"
2016-01-27 17:51:45

$date -d '1 seconds ago' "+%Y-%m-%d %H:%M:%S"
2016-01-27 17:52:59

(4) 比较时间

#!/bin/bash
 
date1="2008-4-09 12:00:00"
date2="2008-4-10 15:00:00"
 
t1=`date -d "$date1" +%s`
t2=`date -d "$date2" +%s`
 
if [ $t1 -gt $t2 ]; then
    echo "$date1 > $date2"
elif [ $t1 -eq $t2 ]; then
    echo "$date1 == $date2"
else
    echo "$date1 < $date2"
fi

 

 
 
 
 
#/bin/bash
#输出 年-月-日
yesterday=`date -d '1 days ago' "+%Y-%m-%d"`
echo $yesterday
my_array=( 'a' 'b' 'c' )
# 'ssh {} "scp /data/visitlog/{} root@d:/data/mapReduceVisitorLog/{}/"'
# 遍历数组
for i in ${my_array[*]}
do
echo $i
s="ssh ${i} 'scp /data/visitlog/*${yesterday} root@d:/data/mapReduceVisitorLog/${i}/'"
echo $s
eval $s
s="ssh ${i} 'scp /data/unionlog/*${yesterday} root@d:/data/mapReduceYunMengLog/${i}/'"
echo $s
eval $s
done




无限循环

while true;do echo $(date +%Y%m%d-%H:%M:%S);done;

无限打印当前时间


#!bin/bash
while true
do
    sleep 1s
    time3=$(date "+%Y-%m-%d %H:%M:%S")
    echo $time3
done

 

获得当天的日期

date +%Y-%m-%d

输出: 2011-07-28

 

将当前日期赋值给DATE变量
DATE=$(date +%Y%m%d)

有时候我们需要使用今天之前或者往后的日期,这时可以使用date的 -d参数

 

获取明天的日期

date -d next-day +%Y%m%d

获取昨天的日期

date -d last-day +%Y%m%d

获取上个月的年和月

date -d last-month +%Y%m

获取下个月的年和月
date -d next-month +%Y%m

获取明年的年份
date -d next-year +%Y

 

下面是一些date参数的说明和一些例子


名称 : date 
使用权限 : 所有使用者 
使用方式 : date [-u] [-d datestr] [-s datestr] [--utc] [--universal] [--date=datestr] [--set=datestr] [--help] [--version] [+FORMAT] [MMDDhhmm[[CC]YY][.ss]] 
说明 : date 能用来显示或设定系统的日期和时间,在显示方面,使用者能设定欲显示的格式,格式设定为一个加号后接数个标记,其中可用的标记列表如下 : 
时间方面 : 
% : 印出 
% %n : 下一行 
%t : 跳格 
%H : 小时(00..23) 
%I : 小时(01..12) 
%k : 小时(0..23) 
%l : 小时(1..12) 
%M : 分钟(00..59) 
%p : 显示本地 AM 或 PM 
%r : 直接显示时间 (12 小时制,格式为 hh:mm:ss [AP]M) 
%s : 从 1970 年 1 月 1 日 00:00:00 UTC 到目前为止的秒数 %S : 秒(00..61) 
%T : 直接显示时间 (24 小时制) 
%X : 相当于 %H:%M:%S 
%Z : 显示时区 
日期方面 : 
%a : 星期几 (Sun..Sat) 
%A : 星期几 (Sunday..Saturday) 
%b : 月份 (Jan..Dec) 
%B : 月份 (January..December) 
%c : 直接显示日期和时间 
%d : 日 (01..31) 
%D : 直接显示日期 (mm/dd/yy) 
%h : 同 %b 
%j : 一年中的第几天 (001..366) 
%m : 月份 (01..12) 
%U : 一年中的第几周 (00..53) (以 Sunday 为一周的第一天的情形) 
%w : 一周中的第几天 (0..6) 
%W : 一年中的第几周 (00..53) (以 Monday 为一周的第一天的情形) 
%x : 直接显示日期 (mm/dd/yy) 
%y : 年份的最后两位数字 (00.99) 
%Y : 完整年份 (0000..9999) 
若是不以加号作为开头,则表示要设定时间,而时间格式为 MMDDhhmm[[CC]YY][.ss], 
其中 MM 为月份, 
DD 为日, 
hh 为小时, 
mm 为分钟, 
CC 为年份前两位数字, 
YY 为年份后两位数字, 
ss 为秒数 
把计 : 
-d datestr : 显示 datestr 中所设定的时间 (非系统时间) 
--help : 显示辅助讯息 
-s datestr : 将系统时间设为 datestr 中所设定的时间 
-u : 显示目前的格林威治时间 
--version : 显示版本编号 
例子 : 
显示时间后跳行,再显示目前日期 : date +%T%n%D 
显示月份和日数 : date +%B %d 
显示日期和设定时间(12:34:56) : date --date 12:34:56 
设置系统当前时间(12:34:56):date --s 12:34:56 
注 意 : 当你不希望出现无意义的 0 时(比如说 1999/03/07),则能在标记中插入 - 符号,比如说 date +%-H:%-M:%-S 会把时分秒中无意义的 0 给去掉,像是原本的 08:09:04 会变为 8:9:4。另外,只有取得权限者(比如说 root)才能设定系统时间。 当你以 root 身分更改了系统时间之后,请记得以 clock -w 来将系统时间写入 CMOS 中,这样下次重新开机时系统时间才会持续抱持最新的正确值。 
ntp时间同步 
linux系统下默认安装了ntp服务,手动进行ntp同步如下 
ntpdate ntp1.nl.net 
当然,也能指定其他的ntp服务器 
------------------------------------------------------------------- 
扩展功能 
date 工具可以完成更多的工作,不仅仅只是打印出当前的系统日期。您可以使用它来得到给定的日期究竟是星期几,并得到相对于当前日期的相对日期。了解某一天是星期几 
GNU 对 date 命令的另一个扩展是 -d 选项,当您的桌上没有日历表时(UNIX 用户不需要日历表),该选项非常有用。使用这个功能强大的选项,通过将日期作为引号括起来的参数提供,您可以快速地查明一个特定的日期究竟是星期几: 
&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-2" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-3" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-4" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-5" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-6" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-7" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-8" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-9" class="mo"&amp;amp;amp;amp;amp;gt;"&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-10" class="mi"&amp;amp;amp;amp;amp;gt;n&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-11" class="mi"&amp;amp;amp;amp;amp;gt;o&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-12" class="mi"&amp;amp;amp;amp;amp;gt;v&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-13" class="mn"&amp;amp;amp;amp;amp;gt;22&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-14" class="mo"&amp;amp;amp;amp;amp;gt;"&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-15" class="mi"&amp;amp;amp;amp;amp;gt;W&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-16" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-17" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-18" class="mi"&amp;amp;amp;amp;amp;gt;N&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-19" class="mi"&amp;amp;amp;amp;amp;gt;o&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-20" class="mi"&amp;amp;amp;amp;amp;gt;v&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-21" class="mn"&amp;amp;amp;amp;amp;gt;22&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-22" class="mn"&amp;amp;amp;amp;amp;gt;00&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-23" class="mo"&amp;amp;amp;amp;amp;gt;:&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-24" class="mn"&amp;amp;amp;amp;amp;gt;00&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-25" class="mo"&amp;amp;amp;amp;amp;gt;:&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-26" class="mn"&amp;amp;amp;amp;amp;gt;00&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-27" class="mi"&amp;amp;amp;amp;amp;gt;E&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-28" class="mi"&amp;amp;amp;amp;amp;gt;S&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-29" class="mi"&amp;amp;amp;amp;amp;gt;T&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-30" class="mn"&amp;amp;amp;amp;amp;gt;2006date−d"nov22"WedNov2200:00:00EST2006 
在本示例中,您可以看到今年的 11 月 22 日是星期三。 
所以,假设在 11 月 22 日召开一个重大的会议,您可以立即了解到这一天是星期三,而这一天您将赶到驻地办公室。 
获得相对日期 
d 选项还可以告诉您,相对于 当前日期若干天的究竟是哪一天,从现在开始的若干天或若干星期以后,或者以前(过去)。通过将这个相对偏移使用引号括起来,作为 -d 选项的参数,就可以完成这项任务。 
例如,您需要了解两星期以后的日期。如果您处于 Shell 提示符处,那么可以迅速地得到答案: 
&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-32" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-33" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-34" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-35" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-36" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-37" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-38" class="msup"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-39" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-40" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;prime;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-41" class="mn"&amp;amp;amp;amp;amp;gt;2&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-42" class="mi"&amp;amp;amp;amp;amp;gt;w&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-43" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-44" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-45" class="mi"&amp;amp;amp;amp;amp;gt;k&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-46" class="msup"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-47" class="mi"&amp;amp;amp;amp;amp;gt;s&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-48" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;prime;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-49" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-50" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-51" class="mo"&amp;amp;amp;amp;amp;gt;关&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-52" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-53" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-54" class="mo"&amp;amp;amp;amp;amp;gt;于&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-55" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-56" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-57" class="mo"&amp;amp;amp;amp;amp;gt;使&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-58" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-59" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-60" class="mo"&amp;amp;amp;amp;amp;gt;用&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-61" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-62" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-63" class="mo"&amp;amp;amp;amp;amp;gt;该&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-64" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-65" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-66" class="mo"&amp;amp;amp;amp;amp;gt;命&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-67" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-68" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-69" class="mo"&amp;amp;amp;amp;amp;gt;令&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-70" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-71" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-72" class="mo"&amp;amp;amp;amp;amp;gt;,&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-73" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-74" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-75" class="mo"&amp;amp;amp;amp;amp;gt;还&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-76" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-77" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-78" class="mo"&amp;amp;amp;amp;amp;gt;有&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-79" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-80" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-81" class="mo"&amp;amp;amp;amp;amp;gt;其&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-82" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-83" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-84" class="mo"&amp;amp;amp;amp;amp;gt;他&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-85" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-86" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-87" class="mo"&amp;amp;amp;amp;amp;gt;一&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-88" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-89" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-90" class="mo"&amp;amp;amp;amp;amp;gt;些&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-91" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-92" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-93" class="mo"&amp;amp;amp;amp;amp;gt;重&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-94" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-95" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-96" class="mo"&amp;amp;amp;amp;amp;gt;要&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-97" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-98" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-99" class="mo"&amp;amp;amp;amp;amp;gt;的&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-100" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-101" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-102" class="mo"&amp;amp;amp;amp;amp;gt;方&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-103" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-104" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-105" class="mo"&amp;amp;amp;amp;amp;gt;法&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-106" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-107" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-108" class="mo"&amp;amp;amp;amp;amp;gt;。&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-109" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-110" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-111" class="mo"&amp;amp;amp;amp;amp;gt;使&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-112" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-113" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-114" class="mo"&amp;amp;amp;amp;amp;gt;用&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-115" class="mi"&amp;amp;amp;amp;amp;gt;n&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-116" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-117" class="mi"&amp;amp;amp;amp;amp;gt;x&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-118" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-119" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-120" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-121" class="mo"&amp;amp;amp;amp;amp;gt;/&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-122" class="mi"&amp;amp;amp;amp;amp;gt;l&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-123" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-124" class="mi"&amp;amp;amp;amp;amp;gt;s&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-125" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-126" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-127" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-128" class="mo"&amp;amp;amp;amp;amp;gt;指&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-129" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-130" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-131" class="mo"&amp;amp;amp;amp;amp;gt;令&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-132" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-133" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-134" class="mo"&amp;amp;amp;amp;amp;gt;,&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-135" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-136" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-137" class="mo"&amp;amp;amp;amp;amp;gt;您&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-138" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-139" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-140" class="mo"&amp;amp;amp;amp;amp;gt;可&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-141" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-142" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-143" class="mo"&amp;amp;amp;amp;amp;gt;以&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-144" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-145" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-146" class="mo"&amp;amp;amp;amp;amp;gt;得&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-147" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-148" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-149" class="mo"&amp;amp;amp;amp;amp;gt;到&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-150" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-151" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-152" class="mo"&amp;amp;amp;amp;amp;gt;以&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-153" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-154" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-155" class="mo"&amp;amp;amp;amp;amp;gt;后&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-156" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-157" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-158" class="mo"&amp;amp;amp;amp;amp;gt;的&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-159" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-160" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-161" class="mo"&amp;amp;amp;amp;amp;gt;星&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-162" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-163" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-164" class="mo"&amp;amp;amp;amp;amp;gt;期&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-165" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-166" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-167" class="mo"&amp;amp;amp;amp;amp;gt;几&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-168" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-169" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-170" class="mo"&amp;amp;amp;amp;amp;gt;是&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-171" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-172" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-173" class="mo"&amp;amp;amp;amp;amp;gt;哪&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-174" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-175" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-176" class="mo"&amp;amp;amp;amp;amp;gt;一&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-177" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-178" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-179" class="mo"&amp;amp;amp;amp;amp;gt;天&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-180" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-181" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-182" class="mo"&amp;amp;amp;amp;amp;gt;:
date−d′2weeks′关于使用该命令,还有其他一些重要的方法。使用next/last指令,您可以得到以后的星期几是哪一天: date -d ’next monday’ (下周一的日期) 
&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-184" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-185" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-186" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-187" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-188" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-189" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-190" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-191" class="mi"&amp;amp;amp;amp;amp;gt;n&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-192" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-193" class="mi"&amp;amp;amp;amp;amp;gt;x&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-194" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-195" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-196" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-197" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-198" class="mi"&amp;amp;amp;amp;amp;gt;y&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-199" class="mo"&amp;amp;amp;amp;amp;gt;+
date−dnext−day+ date -d last-day +%Y%m%d(昨天的日期) 或者:date -d yesterday +%Y%m%d 
&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-201" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-202" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-203" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-204" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-205" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-206" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-207" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-208" class="mi"&amp;amp;amp;amp;amp;gt;l&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-209" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-210" class="mi"&amp;amp;amp;amp;amp;gt;s&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-211" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-212" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-213" class="mi"&amp;amp;amp;amp;amp;gt;m&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-214" class="mi"&amp;amp;amp;amp;amp;gt;o&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-215" class="mi"&amp;amp;amp;amp;amp;gt;n&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-216" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-217" class="mi"&amp;amp;amp;amp;amp;gt;h&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-218" class="mo"&amp;amp;amp;amp;amp;gt;+
date−dlast−month+ date -d next-month +%Y%m(下个月是几月) 
使用 ago 指令,您可以得到过去的日期: 
&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-220" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-221" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-222" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-223" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-224" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-225" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-226" class="msup"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-227" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-228" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;prime;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-229" class="mn"&amp;amp;amp;amp;amp;gt;30&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-230" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-231" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-232" class="mi"&amp;amp;amp;amp;amp;gt;y&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-233" class="mi"&amp;amp;amp;amp;amp;gt;s&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-234" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-235" class="mi"&amp;amp;amp;amp;amp;gt;g&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-236" class="msup"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-237" class="mi"&amp;amp;amp;amp;amp;gt;o&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-238" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;prime;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-239" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-240" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-241" class="mo"&amp;amp;amp;amp;amp;gt;(&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-242" class="mn"&amp;amp;amp;amp;amp;gt;30&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-243" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-244" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-245" class="mo"&amp;amp;amp;amp;amp;gt;天&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-246" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-247" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-248" class="mo"&amp;amp;amp;amp;amp;gt;前&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-249" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-250" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-251" class="mo"&amp;amp;amp;amp;amp;gt;的&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-252" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-253" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-254" class="mo"&amp;amp;amp;amp;amp;gt;日&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-255" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-256" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-257" class="mo"&amp;amp;amp;amp;amp;gt;期&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-258" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-259" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-260" class="mo"&amp;amp;amp;amp;amp;gt;)&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-261" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-262" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-263" class="mo"&amp;amp;amp;amp;amp;gt;您&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-264" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-265" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-266" class="mo"&amp;amp;amp;amp;amp;gt;可&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-267" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-268" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-269" class="mo"&amp;amp;amp;amp;amp;gt;以&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-270" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-271" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-272" class="mo"&amp;amp;amp;amp;amp;gt;使&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-273" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-274" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-275" class="mo"&amp;amp;amp;amp;amp;gt;用&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-276" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-277" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-278" class="mo"&amp;amp;amp;amp;amp;gt;负&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-279" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-280" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-281" class="mo"&amp;amp;amp;amp;amp;gt;数&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-282" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-283" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-284" class="mo"&amp;amp;amp;amp;amp;gt;以&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-285" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-286" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-287" class="mo"&amp;amp;amp;amp;amp;gt;得&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-288" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-289" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-290" class="mo"&amp;amp;amp;amp;amp;gt;到&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-291" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-292" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-293" class="mo"&amp;amp;amp;amp;amp;gt;相&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-294" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-295" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-296" class="mo"&amp;amp;amp;amp;amp;gt;反&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-297" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-298" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-299" class="mo"&amp;amp;amp;amp;amp;gt;的&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-300" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-301" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-302" class="mo"&amp;amp;amp;amp;amp;gt;日&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-303" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-304" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-305" class="mo"&amp;amp;amp;amp;amp;gt;期&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-306" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-307" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-308" class="mo"&amp;amp;amp;amp;amp;gt;:
date−d′30daysago′(30天前的日期)您可以使用负数以得到相反的日期: date -d ’dec 14 -2 weeks’ (相对:dec 14这个日期的两周前的日期) 
&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-310" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-311" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-312" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-313" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-314" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-315" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-316" class="msup"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-317" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-318" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;prime;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-319" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-320" class="mn"&amp;amp;amp;amp;amp;gt;100&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-321" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-322" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-323" class="mi"&amp;amp;amp;amp;amp;gt;y&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-324" class="msup"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-325" class="mi"&amp;amp;amp;amp;amp;gt;s&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-326" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;prime;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-327" class="mo"&amp;amp;amp;amp;amp;gt;(&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-328" class="mn"&amp;amp;amp;amp;amp;gt;100&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-329" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-330" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-331" class="mo"&amp;amp;amp;amp;amp;gt;天&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-332" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-333" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-334" class="mo"&amp;amp;amp;amp;amp;gt;以&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-335" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-336" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-337" class="mo"&amp;amp;amp;amp;amp;gt;前&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-338" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-339" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-340" class="mo"&amp;amp;amp;amp;amp;gt;的&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-341" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-342" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-343" class="mo"&amp;amp;amp;amp;amp;gt;日&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-344" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-345" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-346" class="mo"&amp;amp;amp;amp;amp;gt;期&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-347" class="mo"&amp;amp;amp;amp;amp;gt;)
date−d′−100days′(100天以前的日期) date -d ’50 days’(50天后的日期) 
这个技巧非常有用,它可以根据将来的日期为自己设置提醒,可能是在脚本或 Shell 启动文件中,如下所示: 
DAY=`date -d ’2 weeks’ +"%b %d"` 
if test "`echo &amp;amp;amp;amp;amp;lt;span id="MathJax-Span-349" class="noError"&amp;amp;amp;amp;amp;gt;DAY`"&amp;amp;amp;amp;amp;amp;nbsp;=&amp;amp;amp;amp;amp;amp;nbsp;"Aug&amp;amp;amp;amp;amp;amp;nbsp;16";&amp;amp;amp;amp;amp;amp;nbsp;then&amp;amp;amp;amp;amp;amp;nbsp;echo&amp;amp;amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;amp;amp;rsquo;Product&amp;amp;amp;amp;amp;amp;nbsp;launch&amp;amp;amp;amp;amp;amp;nbsp;is&amp;amp;amp;amp;amp;amp;nbsp;now&amp;amp;amp;amp;amp;amp;nbsp;two&amp;amp;amp;amp;amp;amp;nbsp;weeks&amp;amp;amp;amp;amp;amp;nbsp;away!&amp;amp;amp;amp;amp;amp;rsquo;;&amp;amp;amp;amp;amp;amp;nbsp;fi&amp;amp;amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;amp;amp;nbsp;##############################&amp;amp;amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;amp;amp;nbsp;unix&amp;amp;amp;amp;amp;amp;nbsp;shell中的日期格式转换&amp;amp;amp;amp;amp;lt;span class="MJX_Assistive_MathML"&amp;amp;amp;amp;amp;gt;DAY`"&amp;amp;amp;amp;amp;amp;nbsp;=&amp;amp;amp;amp;amp;amp;nbsp;"Aug&amp;amp;amp;amp;amp;amp;nbsp;16";&amp;amp;amp;amp;amp;amp;nbsp;then&amp;amp;amp;amp;amp;amp;nbsp;echo&amp;amp;amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;amp;amp;rsquo;Product&amp;amp;amp;amp;amp;amp;nbsp;launch&amp;amp;amp;amp;amp;amp;nbsp;is&amp;amp;amp;amp;amp;amp;nbsp;now&amp;amp;amp;amp;amp;amp;nbsp;two&amp;amp;amp;amp;amp;amp;nbsp;weeks&amp;amp;amp;amp;amp;amp;nbsp;away!&amp;amp;amp;amp;amp;amp;rsquo;;&amp;amp;amp;amp;amp;amp;nbsp;fi&amp;amp;amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;amp;amp;nbsp;##############################&amp;amp;amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;amp;amp;nbsp;unix&amp;amp;amp;amp;amp;amp;nbsp;shell中的日期格式转换&amp;amp;amp;amp;amp;amp;nbsp;t_t="Jul&amp;amp;amp;amp;amp;amp;nbsp; 1 21:29"&amp;amp;amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;amp;lt;br /&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span class="MathJax_Preview"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Element-8-Frame" class="MathJax" data-mathml="&amp;amp;amp;amp;amp;amp;lt;math xmlns=&amp;amp;amp;amp;amp;amp;quot;http://www.w3.org/1998/Math/MathML&amp;amp;amp;amp;amp;amp;quot;&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;mi&amp;amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;amp;lt;/mi&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;mi&amp;amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;amp;lt;/mi&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;mi&amp;amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;amp;lt;/mi&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;mi&amp;amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;amp;lt;/mi&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;mo&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;amp;quot;&amp;amp;amp;amp;amp;amp;lt;/mo&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;mo&amp;amp;amp;amp;amp;amp;gt;+&amp;amp;amp;amp;amp;amp;lt;/mo&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;/math&amp;amp;amp;amp;amp;amp;gt;"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-350" class="math"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-351" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-352" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-353" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-354" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-355" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-356" class="mo"&amp;amp;amp;amp;amp;gt;"&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-357" class="mo"&amp;amp;amp;amp;amp;gt;+
date"+t_t" # &amp;amp;amp;amp;amp;lt;span id="MathJax-Span-359" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-360" class="msubsup"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-361" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-362" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-363" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-364" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-365" class="mo"&amp;amp;amp;amp;amp;gt;的&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-366" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-367" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-368" class="mo"&amp;amp;amp;amp;amp;gt;格&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-369" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-370" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-371" class="mo"&amp;amp;amp;amp;amp;gt;式&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-372" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-373" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-374" class="mo"&amp;amp;amp;amp;amp;gt;是&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-375" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-376" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-377" class="mo"&amp;amp;amp;amp;amp;gt;比&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-378" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-379" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-380" class="mo"&amp;amp;amp;amp;amp;gt;较&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-381" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-382" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-383" class="mo"&amp;amp;amp;amp;amp;gt;随&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-384" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-385" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-386" class="mo"&amp;amp;amp;amp;amp;gt;意&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-387" class="texatom"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-388" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-389" class="mo"&amp;amp;amp;amp;amp;gt;的&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-390" class="mn"&amp;amp;amp;amp;amp;gt;2008&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-391" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-392" class="mn"&amp;amp;amp;amp;amp;gt;07&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-393" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-394" class="mn"&amp;amp;amp;amp;amp;gt;01&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-395" class="mn"&amp;amp;amp;amp;amp;gt;21&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-396" class="mo"&amp;amp;amp;amp;amp;gt;:&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-397" class="mn"&amp;amp;amp;amp;amp;gt;29&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-398" class="mo"&amp;amp;amp;amp;amp;gt;:&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-399" class="mn"&amp;amp;amp;amp;amp;gt;00tt的格式是比较随意的2008−07−0121:29:00 date +%b/%d/%G -d "2008-07-01" 
Jul/01/2008 

unix shell中的日期之间间隔的天数 
&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-401" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-402" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-403" class="mi"&amp;amp;amp;amp;amp;gt;x&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-404" class="mi"&amp;amp;amp;amp;amp;gt;p&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-405" class="msup"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-406" class="mi"&amp;amp;amp;amp;amp;gt;r&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-407" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;prime;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-408" class="msup"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-409" class="mo"&amp;amp;amp;amp;amp;gt;(&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-410" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;prime;
expr′(′(date +%s -d "2008-07-02") - &amp;amp;amp;amp;amp;lt;span id="MathJax-Span-412" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-413" class="mo"&amp;amp;amp;amp;amp;gt;(&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-414" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-415" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-416" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-417" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-418" class="mo"&amp;amp;amp;amp;amp;gt;+(date+ a=`date +%Y-%m-%d` 
&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-420" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-421" class="mi"&amp;amp;amp;amp;amp;gt;b&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-422" class="mo"&amp;amp;amp;amp;amp;gt;=&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-423" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lsquo;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-424" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-425" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-426" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-427" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-428" class="mo"&amp;amp;amp;amp;amp;gt;+
b=‘date+a +36 hours"` 
10天前: 
&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-430" class="mrow"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-431" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-432" class="mi"&amp;amp;amp;amp;amp;gt;a&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-433" class="mi"&amp;amp;amp;amp;amp;gt;t&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-434" class="mi"&amp;amp;amp;amp;amp;gt;e&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-435" class="mo"&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;minus;&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-436" class="mi"&amp;amp;amp;amp;amp;gt;d&amp;amp;amp;amp;amp;lt;span id="MathJax-Span-437" class="mo"&amp;amp;amp;amp;amp;gt;"
date−d"a -10 days" 
Sun Jun 22 00:00:00 CST 2008 

以指定格式显示文件更改后最后日期,如yyyy-mm-dd hh24:mi:ss 
$ date "+%Y-%m-%d %H:%M:%S" -r test.bak 
2008-07-01 21:28:55

 

date命令的帮助信息
 [root@localhost source]# date --help
用法:date [选项]... [+格式]
 或:date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
以给定的格式显示当前时间,或是设置系统日期。

  -d,--date=字符串              显示指定字符串所描述的时间,而非当前时间
  -f,--file=日期文件            类似--date,从日期文件中按行读入时间描述
  -r, --reference=文件          显示文件指定文件的最后修改时间
  -R, --rfc-2822                以RFC 2822格式输出日期和时间
                                例如:2006年8月7日,星期一 12:34:56 -0600
      --rfc-3339=TIMESPEC      以RFC 3339 格式输出日期和时间。
                                TIMESPEC=`date',`seconds',或 `ns' 
                                表示日期和时间的显示精度。
                                日期和时间单元由单个的空格分开:
                                2006-08-07 12:34:56-06:00
  -s, --set=字符串              设置指定字符串来分开时间
  -u, --utc, --universal        输出或者设置协调的通用时间
      --help            显示此帮助信息并退出
      --version        显示版本信息并退出

给定的格式FORMAT 控制着输出,解释序列如下:

  %%    一个文字的 %
  %a    当前locale 的星期名缩写(例如: 日,代表星期日)
  %A    当前locale 的星期名全称 (如:星期日)
  %b    当前locale 的月名缩写 (如:一,代表一月)
  %B    当前locale 的月名全称 (如:一月)
  %c    当前locale 的日期和时间 (如:2005年3月3日 星期四 23:05:25)
  %C    世纪;比如 %Y,通常为省略当前年份的后两位数字(例如:20)
  %d    按月计的日期(例如:01)
  %D    按月计的日期;等于%m/%d/%y
  %e    按月计的日期,添加空格,等于%_d
  %F    完整日期格式,等价于 %Y-%m-%d
  %g    ISO-8601 格式年份的最后两位 (参见%G)
  %G    ISO-8601 格式年份 (参见%V),一般只和 %V 结合使用
  %h    等于%b
  %H    小时(00-23)
  %I    小时(00-12)
  %c    按年计的日期(001-366)
  %k    时(0-23)
  %l    时(1-12)
  %m    月份(01-12)
  %M    分(00-59)
  %n    换行
  %N    纳秒(000000000-999999999)
  %p    当前locale 下的"上午"或者"下午",未知时输出为空
  %P    与%p 类似,但是输出小写字母
  %r    当前locale 下的 12 小时时钟时间 (如:11:11:04 下午)
  %R    24 小时时间的时和分,等价于 %H:%M
  %s    自UTC 时间 1970-01-01 00:00:00 以来所经过的秒数
  %S    秒(00-60)
  %t    输出制表符 Tab
  %T    时间,等于%H:%M:%S
  %u    星期,1 代表星期一
  %U    一年中的第几周,以周日为每星期第一天(00-53)
  %V    ISO-8601 格式规范下的一年中第几周,以周一为每星期第一天(01-53)
  %w    一星期中的第几日(0-6),0 代表周一
  %W    一年中的第几周,以周一为每星期第一天(00-53)
  %x    当前locale 下的日期描述 (如:12/31/99)
  %X    当前locale 下的时间描述 (如:23:13:48)
  %y    年份最后两位数位 (00-99)
  %Y    年份
  %z +hhmm              数字时区(例如,-0400)
  %:z +hh:mm            数字时区(例如,-04:00)
  %::z +hh:mm:ss        数字时区(例如,-04:00:00)
  %:::z                数字时区带有必要的精度 (例如,-04,+05:30)
  %Z                    按字母表排序的时区缩写 (例如,EDT)

 

参考:

http://www.cnblogs.com/try-better-tomorrow/p/5030640.html

http://www.linuxidc.com/Linux/2013-03/81039.htm

 

https://www.cnblogs.com/lonelywolfmoutain/p/6165426.html

 

bash  传参

 

mkdir -p /testxiaole/test-cmd-`date '+%Y-%m-%d-%H-%M-%S'`
mkdir -p ~/testxiaole/test-cmd-`date '+%Y-%m-%d-%H-%M-%S'`

 


文件头
total 22500
    4 drwxr-xr-x   3 root root     4096 Oct 30 22:24 .
    4 dr-xr-x---.  8 root root     4096 Oct 30 22:24 ..
    4 -rwxr-xr-x   1 root root      200 Oct 30 22:24 gdb_time_random_once
    4 -rwxr-xr-x   1 root root      175 Oct 30 22:24 gdb_time_random_once_nh.py
    4 -rwxr-xr-x   1 root root      200 Oct 30 22:23 gdb_time_random_once.py
    4 -rw-r--r--   1 root root      165 Oct 30 20:16 gdb_time_random.py
    4 drwxr-xr-x  18  501 test     4096 Oct 30 20:02 Python-3.6.8
22472 -rw-r--r--   1 root root 23010188 Oct 30 17:10 Python-3.6.8.tgz
[root@gateway test]# ./gdb_time_random_once_nh.py 
./gdb_time_random_once_nh.py: line 1: import: command not found
./gdb_time_random_once_nh.py: line 3: syntax error near unexpected token `('
./gdb_time_random_once_nh.py: line 3: `def ftime():'
[root@gateway test]# cat gdb_time_random_once_nh.py 
import time,random

def ftime():
    print(1)
    print(time.time())

def frandom():
    print(1)
    print(random.random())

#while True:
if  True:
    ftime()
    frandom()
[root@gateway test]# cat gdb_time_random_once
#!/usr/local/bin/python3
import time,random

  

#!/usr/local/bin/python3 执行文件的路径

 

#!/bin/bash
# 参数个数 文件名 第一个参数
# 1 ./myQuick.sh test_hex
echo $# $0 $1
# 输出原始字符串
# gcc -c $1.c -o $1
cmd='gcc -c $1.c -o $1'
echo $cmd
# 输入含有代表变量的字符串
# gcc -c test_hex.c -o test_hex
cmd="gcc -c $1.c -o $1"
echo $cmd

# 执行
cmd=`gcc $1.c -o $1;chmod +x $1;./$1`
echo $cmd

  

#!/bin/bash
hostset=('hadoop-name' 'hadoop-data-a' 'hadoop-data-b')
for i in ${hostset[@]}; do
    cmd=`ssh $i "mkdir -p ~/test/hadoop/;ls;"`;
    echo $i $cmd;
done

  

#!/bin/bash
hostset=('hadoop-name' 'hadoop-data-a' 'hadoop-data-b')
for i in ${hostset[@]}; do
    cmd=`ssh $i "mkdir -p ~/test1/hadoop/;ls;"`;
    echo $i $cmd;
done
# 函数传入参数
dataNodes(){
    echo $1;
}
dataNodes `echo 3`

dataNodesSet=('hadoop-data-a' 'hadoop-data-b')
cmd='mkdir -p ~/testa0/hadoop/;'
dataNodesSsh(){
    for i in ${dataNodesSet[@]}; do
        eval  `ssh $i $cmd`
    done
}
dataNodesSsh
# '.` 形成.
cmd='mkdir -p ~/testb'`date '+%Y-%m-%d-%H-%M-%S'`'/hadoop/;'
dataNodesSsh

  

 在bash中加入时间变量

*/1 * * * * cd /root/Shawn/load_balance_app1/5000/app1; git pull >> /root/Shawn/log/app1/git/5000;

# app1

## pull log
10 2 * * * cd /root/Shawn/log/app1/git/;bzip2 --small --best 5000; mv 5000.bz2 `date '+%Y-%m-%d-%H-%M-%S'`5000.bz2;

 

 

mysql命令行连接 导入文件

 mysql -h rm-wz96uncs.com -u root--password="4fbb" < db_schema/links-db-schema.sql

 

显示行号  过滤信息

test@a:~$ ss -atp | grep 3717 | grep ESTAB | grep -n pid
1:ESTAB 0 0 10.200.1.12:37960 1.2.3.86:3717 users:(("cmd",pid=16412,fd=108))
2:ESTAB 0 0 10.200.1.12:37950 1.2.3.86:3717 users:(("cmd",pid=16412,fd=103))
3:ESTAB 0 0 10.200.1.12:42272 1.2.3.38:3717 users:(("cmd",pid=16412,fd=57))
4:ESTAB 0 0 10.200.1.12:42314 1.2.3.38:3717 users:(("cmd",pid=16412,fd=78))
5:ESTAB 0 0 10.200.1.12:37908 1.2.3.86:3717 users:(("cmd",pid=16412,fd=82))
6:ESTAB 0 0 10.200.1.12:37920 1.2.3.86:3717 users:(("cmd",pid=16412,fd=88))
7:ESTAB 0 0 10.200.1.12:37922 1.2.3.86:3717 users:(("cmd",pid=16412,fd=89))
8:ESTAB 0 0 10.200.1.12:42312 1.2.3.38:3717 users:(("cmd",pid=16412,fd=77))

 

 

 

 

 

Linux怎么清空与删除指定大小文件 - CSDN博客 https://blog.csdn.net/skylinethj/article/details/45566601

 

[root@my myv]# ll -hrS
total 1.1G
-rw-r--r-- 1 root root     0 Apr 28 18:32 my6496_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:55 my6312_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:37 my6184_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:30 my5906_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:48 my5894_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:09 my5844_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:40 my5739_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:33 my5661_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:45 my5644_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:28 my5634_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:36 my5443_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:41 my4945_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:50 my4931_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:52 my4849_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:00 my4794_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:24 my4632_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:18 my4598_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:49 my4174_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:43 my4003_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:16 my3906_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:21 my3864_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:48 my3860_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:05 my3834_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:48 my3782_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:59 my3678_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:47 my3323_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:04 my3296_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:49 my3075_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:27 my3038_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 18:22 my2974_5.mp4
-rw-r--r-- 1 root root     0 Apr 28 17:55 my2973_5.mp4
-rw-r--r-- 1 root root  956K Apr 28 17:56 my5742_5.mp4
-rw-r--r-- 1 root root  994K Apr 28 18:02 my3878_5.mp4
-rw-r--r-- 1 root root 1004K Apr 28 17:53 my4853_5.mp4

  

 find . -size -1b | xargs rm -rf

 find . -size -1b | grep mp4 | xargs rm -rf

删除小于1b的文件  

 

 

 

删除生成异常的视频 

 

 

删除 代码运行中的中间文件

 

Input #0, mp3, from '/data/xiaole_dl_img/dlDBimg/mymp3_middle/1524997998_34016590.mp3':
  Metadata:
    encoder         : Lavf57.72.101
  Duration: 00:01:10.42, start: 0.033063, bitrate: 16 kb/s
    Stream #0:0: Audio: mp3, 16000 Hz, mono, s16p, 16 kb/s
Input #1, avi, from '/data/xiaole_dl_img/dlDBimg/myv_middle340165901524997987TEST.avi':
  Duration: 00:01:10.45, start: 0.000000, bitrate: 21078 kb/s
    Stream #1:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj420p(pc, bt470bg/unknown/unknown), 1003x345 [SAR 1:1 DAR 1003:345], 21089 kb/s, 20 fps, 20 tbr, 20 tbn, 20 tbc

  

 

 

在Linux中如何删除指定日期之前的一些文件?_百度知道 https://zhidao.baidu.com/question/579320666.html

 

 

find .  -type f | grep myv | grep TEST |grep avi | xargs rm -f

 

 find .  -mtime +1 -type f | grep myv | grep TEST |grep avi | xargs rm -f

 

从当前时间 算起 的 24小时  之前 的 所有

 

 

find命令_Linux find 命令用法详解:在指定目录下查找文件 http://man.linuxde.net/find

删除20分钟修改的文件  创建 生成  

find . -cmin +20 -type f | grep *avi | xargs rm -f

-amin n : 在过去 n 分钟内被读取过

-anewer file : 比文件 file 更晚被读取过的文件

-atime n : 在过去 n 天过读取过的文件

-cmin n : 在过去 n 分钟内被修改过

-cnewer file :比文件 file 更新的文件

-ctime n : 在过去 n 天过修改过的文件

-empty : 空的文件-gid n or -group name : gid 是 n 或是 group 名称是 name

-ipath p, -path p : 路径名称符合 p 的文件,ipath 会忽略大小写

-name name, -iname name : 文件名称符合 name 的文件。iname 会忽略大小写

-size n : 文件大小 是 n 单位,b 代表 512 位元组的区块,c 表示字元数,k 表示 kilo bytes,w 是二个位元组。-type c : 文件类型是 c 的文件。

Linux find命令 | 菜鸟教程 http://www.runoob.com/linux/linux-comm-find.html

 

 

[root@hadoop2 ~]# 
[root@hadoop2 ~]# 
[root@hadoop2 ~]# ls|grep  ".gz\|.tar\|.zip"
elasticsearch-2.4.1.tar.gz
elasticsearch-analysis-ik-1.10.1.zip
freetype-2.4.0.tar.bz2
libmcrypt-2.5.8.tar.bz2
mcrypt-2.6.8.tar.gz
mhash-0.9.9.9.tar.bz2
mongodb-1.2.10.tgz
mysql-5.7.15.tar.gz
Navicat Premium_11.2.7简体中文版.zip
nginx-1.11.4.tar.gz
pcre-8.39.tar.gz
php-7.0.11.tar.bz2
php_yaf-3.0.4-7.0-nts-vc14-x86.zip
Python-2.7.12.tgz
Python-3.5.2.tar
redis-3.2.4.tar.gz
ruby-1.9.3-p0.tar.gz
ruby-2.0.0-p247.tar.gz
ruby-2.3.1.tar.gz
rubygems-2.6.8.zip
scala-2.12.1.tgz
spark-2.1.0-bin-hadoop2.7.tgz
webbench-1.5.tar.gz
yaml-0.1.4.tar.gz
[root@hadoop2 ~]# rm ls|grep  ".gz\|.tar\|.zip"
rm: cannot remove `ls': No such file or directory
[root@hadoop2 ~]# rm 'ls|grep  ".gz\|.tar\|.zip"'
rm: cannot remove `ls|grep  ".gz\\|.tar\\|.zip"': No such file or directory
[root@hadoop2 ~]# ls|grep  ".gz\|.tar\|.zip"
elasticsearch-2.4.1.tar.gz
elasticsearch-analysis-ik-1.10.1.zip
freetype-2.4.0.tar.bz2
libmcrypt-2.5.8.tar.bz2
mcrypt-2.6.8.tar.gz
mhash-0.9.9.9.tar.bz2
mongodb-1.2.10.tgz
mysql-5.7.15.tar.gz
Navicat Premium_11.2.7简体中文版.zip
nginx-1.11.4.tar.gz
pcre-8.39.tar.gz
php-7.0.11.tar.bz2
php_yaf-3.0.4-7.0-nts-vc14-x86.zip
Python-2.7.12.tgz
Python-3.5.2.tar
redis-3.2.4.tar.gz
ruby-1.9.3-p0.tar.gz
ruby-2.0.0-p247.tar.gz
ruby-2.3.1.tar.gz
rubygems-2.6.8.zip
scala-2.12.1.tgz
spark-2.1.0-bin-hadoop2.7.tgz
webbench-1.5.tar.gz
yaml-0.1.4.tar.gz
[root@hadoop2 ~]# ls|grep  ".gz\|.tar\|.zip" | xargs rm 
rm: cannot remove `Navicat': No such file or directory
rm: cannot remove `Premium_11.2.7简体中文版.zip': No such file or directory
[root@hadoop2 ~]# ls|grep  ".gz\|.tar\|.zip" | xargs rm 
rm: cannot remove `Navicat': No such file or directory
rm: cannot remove `Premium_11.2.7简体中文版.zip': No such file or directory
[root@hadoop2 ~]# ls|grep  ".gz\|.tar" | xargs rm 
rm: missing operand
Try `rm --help' for more information.
[root@hadoop2 ~]# ls|grep  ".gz\|.tar" | xargs rm -rf
[root@hadoop2 ~]# ll -ashS
total 232M
159M -rw-r--r--.  1 root  root  159M Oct 14  2016 jdk-8u101-linux-x64.rpm
 69M -rw-r--r--.  1 root  root   69M Oct 17  2016 Navicat Premium_11.2.7简体中文版.zip
2.2M -rw-------   1 root  root  2.2M May 24 14:40 nohup.out
1.6M -rw-r--r--.  1 root  root  1.6M Dec 13  2016 get-pip.py
856K -rw-r--r--.  1 root  root  855K Feb 19  2007 download.1
 96K -rw-rw-r--.  1  1000  1000  94K Sep  7  2017 package.xml
 68K -rw-r--r--.  1 root  root   68K Oct 23  2016 download
 28K -rw-r--r--.  1 root  root   28K Oct 20  2016 install.log
 20K -rw-------.  1 root  root   20K May 23 22:40 .bash_history
 12K drwxr-xr-x. 25  1045 users  12K Nov  9  2016 ruby-2.0.0-p247
 12K drwxr-xr-x. 26  1044  1044  12K Nov  9  2016 ruby-2.3.1
 12K -rw-r--r--.  1 root  root   11K Oct 23  2016 wget-log.1
 12K -rw-r--r--.  1 root  root   11K Nov 29  2016 dump.rdb
 12K -rw-------   1 root  root  8.9K May 19 09:09 .viminfo
8.0K -rw-r--r--.  1 root  root  7.4K Oct 20  2016 install.log.syslog
8.0K -rw-r--r--.  1 root  root  4.4K Oct 23  2016 wget-log
4.0K dr-xr-x---. 41 root  root  4.0K May 24 14:39 .
4.0K dr-xr-xr-x. 28 root  root  4.0K May 22 09:45 ..
4.0K drwxr-xr-x. 21 root  root  4.0K Dec  5 13:44 anaconda3
4.0K drwxr-xr-x   3 root  root  4.0K Dec  5 13:46 .astropy
4.0K drwx------.  4 root  root  4.0K Dec  5 13:49 .cache
4.0K drwxr-xr-x.  3 root  root  4.0K Oct 19  2017 .conda
4.0K drwxr-xr-x   3 root  root  4.0K Dec  5 13:47 .config
4.0K drwxr-xr-x.  2 root  root  4.0K Aug 21  2017 .continuum
4.0K drwxr-xr-x.  2 root  root  4.0K Oct  9  2017 data
4.0K drwxr-xr-x.  8  1000 users 4.0K Aug  7  2017 freetype-2.4.0
4.0K drwxr-xr-x.  3 root  root  4.0K Nov  9  2016 .gem
4.0K drwx------.  2 root  root  4.0K Nov  8  2016 .gnupg
4.0K drwxr-xr-x.  2 root  root  4.0K Sep  3  2017 invalid_urls
4.0K drwxr-xr-x   3 root  root  4.0K Nov 24 09:10 .ivy2
4.0K drwxrwxrwx.  9 nginx adm   4.0K Oct 22  2016 libmcrypt-2.5.8
4.0K drwxr-xr-x   3 root  root  4.0K Dec  5 13:45 .local
4.0K drwxrwxrwx.  6  1003  1001 4.0K Oct 22  2016 mcrypt-2.6.8
4.0K drwxr-xr-x. 10 root  root  4.0K Oct 22  2016 mhash-0.9.9.9
4.0K drwxr-xr-x. 10 root  root  4.0K Sep 14  2017 mongodb-1.2.10
4.0K drwxr-xr-x   2 root  root  4.0K Nov 23 10:41 mv
4.0K drwxr-xr-x.  9  1001  1001 4.0K Oct 22  2016 nginx-1.11.4
4.0K drwxr-xr-x.  2 root  root  4.0K Nov 20  2017 .oracle_jre_usage
4.0K drwxr-xr-x. 17  1000  1000 4.0K Oct 22  2016 php-7.0.11
4.0K drwxr-xr-x. 11 root  root  4.0K Oct 22  2016 phpredis
4.0K drwxr-xr-x. 16 root  root  4.0K Oct 22  2016 php-yaf
4.0K drwxr-----.  3 root  root  4.0K Oct 22  2016 .pki
4.0K drwxr-xr-x  17 root  root  4.0K Dec  5 13:47 .pycharm_helpers
4.0K drwxrwxr-x. 18  1000  1000 4.0K Jan 16  2017 Python-2.7.12
4.0K drwxrwxr-x. 17  1000  1000 4.0K Dec 13  2016 Python-3.5.2
4.0K drwxrwxr-x.  6 root  root  4.0K May 19 09:09 redis-3.2.4
4.0K drwxr-xr-x.  8 root  root  4.0K Nov  8  2016 rediscluster
4.0K drwxr-xr-x.  8 root  root  4.0K Oct 30  2016 rubygems-2.6.8
4.0K drwxr-xr-x   5 root  root  4.0K Nov 23 21:04 .sbt
4.0K drwx------   2 root  root  4.0K Apr 19 13:58 .ssh
4.0K drwxr-xr-x.  4 root  root  4.0K Oct 23  2017 .subversion
4.0K drwxr-xr-x   3 root  root  4.0K Dec  4 20:17 tmp_py
4.0K drwxr-xr-x.  4 root  root  4.0K Nov 20  2017 tools
4.0K drwxr-xr-x.  3  1001 root  4.0K Oct 27  2016 webbench-1.5
4.0K drwxr-xr-x.  8  1000  1000 4.0K Nov  8  2016 yaml-0.1.4
4.0K -rw-r--r--   1 root  root  4.0K Dec 11 13:56 ghostdriver.log
4.0K -rw-r--r--.  1 root  root  3.2K Sep 21  2016 LICENSE
4.0K -rw-------.  1 root  root  2.3K Nov 29 22:40 .dbshell
4.0K -rw-------.  1 root  root  1.6K Oct 20  2016 anaconda-ks.cfg
4.0K -rw-------   1 root  root  1.0K Nov 21  2017 .rnd
4.0K -rw-------.  1 root  root   753 May 17 17:20 .rediscli_history
4.0K -rw-r--r--   1 root  root   378 Dec  7 10:38 .bashrc
4.0K -rw-r--r--.  1 root  root   280 Sep 21  2016 composer.json
4.0K -rw-r--r--.  1 root  root   176 May 20  2009 .bash_profile
4.0K -rw-r--r--.  1 root  root   176 Aug 21  2017 .bashrc-anaconda3.bak
4.0K -rw-r--r--.  1 root  root   129 Dec  4  2004 .tcshrc
4.0K -rw-------.  1 root  root   128 May 15 09:32 .python_history
4.0K -rw-r--r--.  1 root  root   100 Sep 23  2004 .cshrc
4.0K -r--------   1 root  root    20 May  4 00:00 .erlang.cookie
4.0K -rw-r--r--.  1 root  root    18 May 20  2009 .bash_logout
4.0K -rw-------.  1 root  root    18 Nov 20  2017 .scala_history
4.0K -rw-r--r--.  1 root  root    16 Sep 21  2016 CREDITS
   0 -rw-------.  1 root  root     0 Sep  6  2017 .mongorc.js
[root@hadoop2 ~]# ls|grep  ".gz\|.tar\|rpm" | xargs rm -rf
[root@hadoop2 ~]# ll -ashS
total 74M
 69M -rw-r--r--.  1 root  root   69M Oct 17  2016 Navicat Premium_11.2.7简体中文版.zip
2.2M -rw-------   1 root  root  2.2M May 24 14:41 nohup.out

  linux  的文件名 空格  

 

转义字符

[root@d a]# cd a;find . | grep 09-
-bash: cd: a: No such file or directory
./visit-2018-09-29
./visit-2018-09-28
./visit-2018-09-19
./visit-2018-09-18
./visit-2018-09-22
./visit-2018-09-26
./visit-2018-09-23
./visit-2018-09-20
./visit-2018-09-30
./visit-2018-09-24
./visit-2018-09-21
./visit-2018-09-25
./visit-2018-09-27
[root@d a]# cd a;find . | grep \-09-
-bash: cd: a: No such file or directory
grep: invalid option -- '-'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
[root@d a]# cd a;find . | grep \\-09-
-bash: cd: a: No such file or directory
./visit-2018-09-29
./visit-2018-09-28
./visit-2018-09-19
./visit-2018-09-18
./visit-2018-09-22
./visit-2018-09-26
./visit-2018-09-23
./visit-2018-09-20
./visit-2018-09-30
./visit-2018-09-24
./visit-2018-09-21
./visit-2018-09-25
./visit-2018-09-27
[root@d a]#

 

[root@d c]# cd ../c;find . | grep \\-0- | xargs rm -rf;

 cd ../a;find . | grep \\-11- | xargs rm -rf;cd ../b;find . | grep \\-11- | xargs rm -rf; cd ../c;find . | grep \\-11- | xargs rm -rf;

 

清空 删除指定大小文件   指定时间 分钟 小时 前的 文件

 

posted @ 2017-11-28 07:48  papering  阅读(479)  评论(0编辑  收藏  举报