2016-06-01 43 views
1

我需要以簡單的週期打印當天的所有SVN修訂版,但我無法解析它們。在Bash中打印所有svn修訂日期

我需要的是循環修改每一天。我的問題是獲得一個腳本,例如修改日期和版本號:

log=$(svn log -r {2011-11-01}:Head) 
startDate= #??? get first commit date from log 
startCommit= #?? get first revision number from log 

for $rev in $(log); do 
# revisionDate=??? (similar to startdate) 
# revisionNumber=??? (similar to start commit) 

    if [! $startDate = $revisionDate ]; then  
    echo $revisionDate 
    echo $revisionNumber 
    fi 
done 

這是一個SVN的日誌的例子:

------------------------------------------------------------------------ 
r1619603 | aw | 2014-08-21 23:33:35 +0200 (Thu, 21 Aug 2014) | 2 lines 

YARN-2436. [post-HADOOP-9902] yarn application help doesn't work 

------------------------------------------------------------------------ 
r1619604 | jlowe | 2014-08-21 23:38:16 +0200 (Thu, 21 Aug 2014) | 2 lines 

HADOOP-10893. isolated classloader on the client side. Contributed by Sangjin Lee 

------------------------------------------------------------------------ 
r1619614 | jlowe | 2014-08-22 00:41:34 +0200 (Fri, 22 Aug 2014) | 2 lines 

YARN-2434. RM should not recover containers from previously failed attempt when AM restart is not enabled. Contributed by Jian He 

------------------------------------------------------------------------ 
r1619626 | sandy | 2014-08-22 01:28:44 +0200 (Fri, 22 Aug 2014) | 1 line 

MAPREDUCE-5130. Add missing job config options to mapred-default.xml (Ray Chiang via Sandy Ryza) 
------------------------------------------------------------------------ 
r1619632 | aw | 2014-08-22 01:58:25 +0200 (Fri, 22 Aug 2014) | 1 line 

HADOOP-8896. Javadoc points to Wrong Reader and Writer classes in SequenceFile (Ray Chiang via aw) 
------------------------------------------------------------------------ 
+0

您是否嘗試輸出'$ log'並看着它? – Will

+0

是的,svn log的例子是$ log變量的輸出。 – Botacco

回答

1

svn log輸出可以被重定向到一些文件和可以用於進一步提取有用的信息。 PFB腳本提供所需日期的日誌: -

#!/bin/bash 

svn log > svn_logs_today.txt 
printf "Enter the date in format YYYY-MM-DD for which revision no. to be displayed\n" 
read var 
#today=`date +%Y-%m-%d` 
#if required today variable can be used for extracting todays report 
cat svn_logs_today.txt| grep $var 
+0

不幸的是,這在我的情況下不起作用......將結果打印在一個文件中,然後頂部讀取文件(即使這會花費更多時間),但我需要將數據和修訂版寫入文件的每一行,回到我以前從svn日誌中提取這些變量的問題;-( 這可能是我需要保存的文件的一個示例(或更好的數組) 1619604 2014-08-21 1619614 2014-08-22 1619626 2014-08-23 ... – Botacco