Using svn diff with the --summarize flag returns something like the below. How would we pass this to sed or grep to do the following:
- Remove any lines that start with “D” (deleted files)
- Remove the prefix of the “M”, “A” or “MM” (or any other cases) along with the tab afterward.
- Remove the URL path only leaving the filenames/folder.
- Store in a file
Example:
D https://localhost/example/test1.php
D https://localhost/example/test2.php
M https://localhost/example/test3.php
M https://localhost/example/test4.php
A https://localhost/example/test5.php
M https://localhost/example/test6.php
A https://localhost/example/test7.php
M https://localhost/example/test8.php
M https://localhost/example/test9.php
M https://localhost/example/test10.php
A https://localhost/example/test11.php
M https://localhost/example/test12.php
M https://localhost/example/test13.php
MM https://localhost/example/test.php
M https://localhost/test0.php
Would then become:
/example/test3.php
/example/test4.php
/example/test5.php
/example/test6.php
/example/test7.php
/example/test8.php
/example/test9.php
/example/test10.php
/example/test11.php
/example/test12.php
/example/test13.php
/example/test.php
/test0.php
Like this with
sed:You need to pipe
|the output ofsvntosed. The first part'/^D/d'deletes all the lines starting withDand the seconds/.*host//substitutes everything up tohostwith nothing, to store in to a file use redirect> file.Similar logic with
grep:The first
grepfilters out the lines that start withDand the second uses positive lookahead with-Poto display only the part of the line afterhost.