0

プルしてsvnリポジトリにプッシュするファイルがあります。リポジトリからプルするときに 1 つのファイルの一部を削除し、リポジトリにプッシュするときに同じ部分を追加する必要があります。これは、'git svn fetch' と 'git svn dcommit' によって行われます。

これを削除して追加するには、sed または awk スクリプトが必要です。

GlobalSection(SubversionScc) = preSolution
    Svn-Managed = True
    Manager = AnkhSVN - Subversion Support for Visual Studio
EndGlobalSection

これから:

Global
    GlobalSection(SubversionScc) = preSolution
        Svn-Managed = True
        Manager = AnkhSVN - Subversion Support for Visual Studio
    EndGlobalSection
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Debug|Mixed Platforms = Debug|Mixed Platforms
        Debug|x86 = Debug|x86
        Release|Any CPU = Release|Any CPU
        Release|Mixed Platforms = Release|Mixed Platforms
        Release|x86 = Release|x86
    EndGlobalSection
EndGlobal

編集:awkを使用すると、これを実行してファイルの特定の部分を取得できます

awk -v RS='GlobalSection' '/SubversionScc/ {print RS$0 RS} ' file

これを元に戻して、この部分以外のすべてを取得するにはどうすればよいですか? そして、この部分を後で追加するにはどうすればよいですか

Global

またはそれ以前

EndGlobal

元のファイルに?

4

1 に答える 1

1

sed を使用して特定のセクションを抽出します。

$ sed -n -e '/GlobalSection(SubversionScc/,/EndGlobalSection/p' yourfilename > yoursvnsection
$ cat yoursvnsection
    GlobalSection(SubversionScc) = preSolution
        Svn-Managed = True
        Manager = AnkhSVN - Subversion Support for Visual Studio
    EndGlobalSection

そして、sed を使用してそのファイルを読み戻します。

$ sed '/^Global$/ r yoursvnsection ' < yourfilename
Global
    GlobalSection(SubversionScc) = preSolution
        Svn-Managed = True
        Manager = AnkhSVN - Subversion Support for Visual Studio
    EndGlobalSection
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Debug|Mixed Platforms = Debug|Mixed Platforms
        Debug|x86 = Debug|x86
        Release|Any CPU = Release|Any CPU
        Release|Mixed Platforms = Release|Mixed Platforms
        Release|x86 = Release|x86
    EndGlobalSection
EndGlobal
于 2011-03-14T11:06:03.670 に答える