我有repo status
的以下输出:
project X/Y (*** NO BRANCH ***)
-- A/B/c
-m D/E/f
project Z/ (*** NO BRANCH ***)
-- G/H/i
-m J/K/l
(小写字母是文件,大写是dirs)
前缀为--
的行表示新添加的文件。 repo diff
不包含这些文件,因此我无法创建包含所有差异的修补程序。所以,我只是创建它们的tarball。
问:我可以使用哪些脚本(例如awk
,perl
或python
)来创建这些文件的tarball? tarball应该包含:
X/Y/A/B/c
Z/G/H/i
我认为awk
脚本会是这样的(我不熟悉w /语法):
awk {
BEGIN curdir = '', filelist = []
{
if ($0 == "project") {
curdir = $1
} else if ($0 == "--") {
# insert file specified by $1 into tarball
}
}
}
想法?谢谢!
答案 0 :(得分:2)
你很亲密。这是一些建议:
/^project/ {
dir = $2
}
$1 == "--" {
fullpath = dir $2 # space between dir and $2 means concatenation
print fullpath
# Do something with fullpath such as
# system("tar ...")
}