问题描述
到目前为止,我使用cygwin作为我熟知的Unix涂鸦,在文件系统和文件内容操作方面取得了一些快速的结果。
一段时间以来,我认为迁移到纯Windows环境以执行此类任务。目前,我正在努力使用以下Bash命令行(是否有类似的命令行来实现相同的目标)?
以下bash命令行搜索所有XML文件在当前目录的文件树中,创建一个压缩的TAR文件(类似于Windows上的ZIP文件)。 XML文件以其相对路径和属性存储在TAR文件中。有了这个TAR,我可以在其他位置提取存储的XML文件,如果我愿意,还可以使用原始文件和目录属性:
find。 -name''* .xml''| xargs tar -czvf data.tgz
或以下bash命令行基于两个环境变量$ DEV和$ BACKUP;它们分别指向development * source *目录和development * backup *目录。命令行在* backup *位置创建development * source *文件树的镜像(替换现有文件,并保留文件''和子目录''属性):
(cd $ DEV; tar -cf - 。)| (cd $ BACKUP; tar -xf - )
是否有任何等效的Powerstell命令行可以获得类似的结果?替换:tar或类似的tar。但是在zip文件中使用与原始文件子树中相同的相对文件子树是很重要的。
提前谢谢
Andi
So far I was using cygwin for my well known Unix scribbles to achieve some quick results on file system and file content manipulations.
Since a while, I consider migrating to a pure Windows environment for such tasks. Currently, I''m struggling with the following Bash command line (is there a similar commandline to achieve the same)?
The following bash command line searches all XML files in the file tree from the current directory and creates a compressed TAR file (analogous to a ZIP file on Windows). The XML files are stored in the TAR file with their relative path and attributes. With this TAR, I could extract the stored XML files at some other location and, if I wished, with the original file and directory attributes:
find . -name ''*.xml'' | xargs tar -czvf data.tgz
Or the following bash command line bases on two environment variables $DEV and $BACKUP; they point to a development *source* directory and to a development *backup* directory respectively. The command line creates a mirror of the development *source* file tree at the *backup* location (replacing existing files and the files'' and sub-directories'' attributes are maintained):
(cd $DEV; tar -cf - . ) | (cd $BACKUP; tar -xf - )
Is there any equivalent Powerstell command line that achieves similar results? Replacement: tar by zip or similar. But it is important to have the same relative file sub-tree in the zip file as in the original file sub-tree.
Thanks in advance
Andi
这篇关于如何从Bash迁移到PowerShell:find。 -name'* .xml'| xargs tar -czvf data.tgz的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!