
这两天在学 shell,打算写一个命令,将最近一天内修改的文件,打成一个压缩包
我试了两种方式,第一种可行:
tar -zcvf lastmode.tar.gz find . -mtime -1 -type f
但是我打算用下面这种方式尝试:
find . -mtime -1 -type f |xargs tar -zcvf lastmode.tar.gz
报错信息如下:
tar: ./\n./deep1/d1_1.sh: Cannot stat: No such file or directory
这个是什么原因?查了半天没思路。 系统是:ubuntu16.4 root 用户 我的目录结构如下:
.
├── \
├── a.c
├── deep1
│ └── d1_1.sh
├── test1.sh
├── test2.sh
├── test3.sh
├── test4.sh
├── test5.sh
└── test6.sh
1 piaochen0 OP find 命令只要再加一个-name "*.sh",这样就没问题,好奇怪 |
2 iwishing 2017 年 12 月 31 日 第二个命令在 17.10 可行 我猜,权限问题? |
3 jworg 2017 年 12 月 31 日 试试加个 find 加个参数 -print |
4 piaochen0 OP |
5 ryd994 2017 年 12 月 31 日 via Android 和 xargs 合用的时候不要 print 最后加-print0 xargs 加 -0 这样会用 null 分隔,没有分割的问题 |
6 jyf007 2018 年 1 月 1 日 please use git,and maybe you use symbol link on the different filesystem |