我在一个非常大的项目中工作。我需要在trunk文件夹下的所有pom.xml文件中执行搜索(我有一百个不同的trunk文件夹),以便查找它是否包含某个依赖项。
我无法下载所有svn存储库,所以我需要进行远程搜索。有没有一种有效的方法呢?
我认为我应该找到trunk文件夹,然后在grep查看其内容之前将所有pom.xml文件搜索到它们中,但我不知道如何在远程服务器上执行此操作:/
答案 0 :(得分:2)
@implementation ArticleWebViewController
NSDate *readingStartTime;
NSDate *readingEndTime;
NSTimeInterval readingTime;
- (void)viewDidLoad
{
[super viewDidLoad];
//start reading timer for the user
readingStartTime = [NSDate date];
}
- (IBAction)doneButtonPressed:(id)sender {
readingEndTime = [NSDate date];
readingTime = [readingEndTime timeIntervalSinceDate:readingStartTime];
NSNumber *wordCount = self.article.wordCount;
NSNumber *totalSeconds = [NSNumber numberWithFloat:roundf(readingTime)];
NSNumber *secondsInMinute = [NSNumber numberWithFloat:60];
NSNumber *wordsPerSecondSpeed = [NSNumber numberWithFloat:totalSeconds.floatValue/secondsInMinute.floatValue];
NSNumber *wordsPerMinuteSpeed = [NSNumber numberWithInt:roundf(wordCount.floatValue/wordsPerSecondSpeed.floatValue)];
NSString *message;
if (readingTime < 60)
{
message = [NSString stringWithFormat:@"Article finished in %@ seconds.", totalSeconds];
}
else if (readingTime < 3600)
{
NSNumber *totalMinutes = [NSNumber numberWithFloat:totalSeconds.floatValue/secondsInMinute.floatValue];
NSNumber *leftOverSeconds = [NSNumber numberWithInt:totalSeconds.intValue % secondsInMinute.intValue];
if (leftOverSeconds > 0)
{
if (totalMinutes.intValue == 1) {
if (leftOverSeconds.intValue == 1)
{
message = [NSString stringWithFormat:@"Article finished in %i minute %i second.", totalMinutes.intValue, leftOverSeconds.intValue];
}
else
{
message = [NSString stringWithFormat:@"Article finished in %i minute %i seconds.", totalMinutes.intValue, leftOverSeconds.intValue];
}
}
else
{
if (leftOverSeconds.intValue == 1) {
message = [NSString stringWithFormat:@"Article finished in %i minutes %i second.", totalMinutes.intValue, leftOverSeconds.intValue];
}
else
{
message = [NSString stringWithFormat:@"Article finished in %i minutes %i seconds.", totalMinutes.intValue, leftOverSeconds.intValue];
}
}
}
else
{
if (totalMinutes.intValue == 1) {
message = [NSString stringWithFormat:@"Article finished in %i minute.", totalMinutes.intValue];
}
else
{
message = [NSString stringWithFormat:@"Article finished in %i minutes.", totalMinutes.intValue];
}
}
}
else
{
NSNumber *secondsInHour = [NSNumber numberWithFloat:3600];
NSNumber *totalHours = [NSNumber numberWithFloat:totalSeconds.floatValue/3600];
NSNumber *leftOverMinutes = [NSNumber numberWithFloat:(totalSeconds.intValue%secondsInHour.intValue)/secondsInMinute.floatValue];
NSNumber *leftOverSeconds = [NSNumber numberWithFloat:totalSeconds.intValue%secondsInHour.intValue];
if (totalHours.intValue == 1) {
if (leftOverMinutes.intValue == 1)
{
if (leftOverSeconds.intValue == 1) {
message = [NSString stringWithFormat:@"Article finished in %i hour %i minute %i second.", totalHours.intValue, leftOverMinutes.intValue, leftOverSeconds.intValue];
}
else {
message = [NSString stringWithFormat:@"Article finished in %i hour %i minute %i seconds.", totalHours.intValue, leftOverMinutes.intValue, leftOverSeconds.intValue];
}
}
else {
if (leftOverSeconds.intValue == 1) {
message = [NSString stringWithFormat:@"Article finished in %i hour %i minutes %i second.", totalHours.intValue, leftOverMinutes.intValue, leftOverSeconds.intValue];
}
else {
message = [NSString stringWithFormat:@"Article finished in %i hour %i minutes %i seconds.", totalHours.intValue, leftOverMinutes.intValue, leftOverSeconds.intValue];
}
}
}
else {
if (leftOverMinutes.intValue == 1)
{
if (leftOverSeconds.intValue == 1) {
message = [NSString stringWithFormat:@"Article finished in %i hours %i minute %i second.", totalHours.intValue, leftOverMinutes.intValue, leftOverSeconds.intValue];
}
else {
message = [NSString stringWithFormat:@"Article finished in %i hours %i minute %i seconds.", totalHours.intValue, leftOverMinutes.intValue, leftOverSeconds.intValue];
}
}
else {
if (leftOverSeconds.intValue == 1) {
message = [NSString stringWithFormat:@"Article finished in %i hours %i minutes %i second.", totalHours.intValue, leftOverMinutes.intValue, leftOverSeconds.intValue];
}
else {
message = [NSString stringWithFormat:@"Article finished in %i hours %i minutes %i seconds.", totalHours.intValue, leftOverMinutes.intValue, leftOverSeconds.intValue];
}
}
}
}
message = [message stringByAppendingString:[NSString stringWithFormat:@" Your speed was %i words per minute. Word count: %i",wordsPerMinuteSpeed.intValue, wordCount.intValue]];
[[[UIAlertView alloc] initWithTitle:@"Done Reading!" message:message delegate:nil cancelButtonTitle:@"ok" otherButtonTitles: nil] show];
}
在树的根目录中,grep需要的文件,构造完整的URL svn ls -R
答案 1 :(得分:0)
使用Find和Grep命令的组合。与(不完全相同)
相似grep -R "192.168.1.5" /etc/
或与Find命令结合使用
find . -name “*.xml” |xargs grep -n “bla”
请参阅here