- 主题:请教一个tar命令
就是把某个目录下面的文件,第一不要把软链接打包进去,
第二把软连接打包进去。
这两个命令该怎么写?
--
FROM 58.38.81.*
-h, --dereference
Follow symlinks; archive and dump the files they point to.
--hard-dereference
Follow hard links; archive and dump the files they refer to.
【 在 javame 的大作中提到: 】
: 就是把某个目录下面的文件,第一不要把软链接打包进去,
: 第二把软连接打包进去。
: 这两个命令该怎么写?
: ...................
--
FROM 120.229.207.*
就是把某个目录下面的文件,第一不要把软链接打包进去,
第二把软连接打包进去。
这两个命令该怎么写?
不同的命令行工具有不同的选项和参数,以下是两种可能的解决方案:假设您使用的是 Linux或类 Unix 操作系统并且您想使用 tar 命令打包目录,那么可以使用以下两个命令:
不包括软链接:
tar -czf archive.tar.gz --no-recursion --exclude='*/*' --exclude='./target' /path/to/directory
包括软链接:
tar -czf archive.tar.gz --no-recursion --exclude='*/*' --exclude='./target' -h /path/to/directory
解释一下:-c: 创建 tar 归档文件-z: 使用 gzip 压缩-f: 指定归档文件名--no-recursion: 不递归查找子目录--exclude='*/*': 排除所有子目录和子文件--exclude='./target': 排除目录下名为 target 的子目录-h: 跟随软链接并把链接文件打包进归档文件如果您使用 Windows 操作系统,则可以使用以下两个命令:
不包括软链接:
powershell Compress-Archive -Path C:\path\to\directory\* -DestinationPath C:\path\to\archive.zip -ExcludeSymbolicLinks
包括软链接:
powershell Compress-Archive -Path C:\path\to\directory\* -DestinationPath C:\path\to\archive.zip
解释一下:Compress-Archive: 使用 PowerShell 压缩归档文件-Path C:\path\to\directory\*: 指定要打包的目录-DestinationPath C:\path\to\archive.zip: 指定目标归档文件名-ExcludeSymbolicLinks: 排除软链接
注意:以上命令仅为示例,实际应用时可能需要根据具体情况进行修改。
【 在 javame 的大作中提到: 】
: 就是把某个目录下面的文件,第一不要把软链接打包进去,第二把软连接打包进去。这两个命令该怎么写? ...
--
FROM 119.85.22.*
学习了,谢谢。
【 在 gnwd 的大作中提到: 】
: 就是把某个目录下面的文件,第一不要把软链接打包进去,
: 第二把软连接打包进去。
: 这两个命令该怎么写?
: ...................
--
FROM 58.38.81.*