bash shell中的重定向用法

时间:2015-06-25 08:35:22

标签: bash shell

Belows是我想要理解的代码:

@interface ViewController () {

    UIView *progressBarView;
    UIView *progressBgView;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Pass the frame where you want to display progress bar
    [self addProgressView:CGRectMake(10, 100, self.view.frame.size.width-20, 30)];

    // Apply colors
    [self setProgressBgColor:[UIColor redColor]];
    [self setProgressBarColor:[UIColor greenColor]];


    // Pass progress percent value here
    [self setPercentage:80];
}

#pragma mark - Progress methods

- (void)addProgressView:(CGRect)progressFrame {

    UIView *progressView = [[UIView alloc] initWithFrame:progressFrame];

    //Progress background view
    progressBgView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, progressView.frame.size.width-10, progressView.frame.size.height-10)];
    progressBgView.backgroundColor = [UIColor redColor];
    progressBgView.layer.cornerRadius = 4.0;

    //Progress animation view
    progressBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, progressBgView.frame.size.height)];
    progressBarView.backgroundColor = [UIColor greenColor];
    progressBarView.layer.cornerRadius = 4.0;

   [progressBgView addSubview:progressBarView];
   [progressView addSubview:progressBgView];
   [self.view addSubview:progressView];
}

- (void)setPercentage:(int)percentage {

    [UIView animateWithDuration:1.0 animations:^{

        [progressBarView setFrame:CGRectMake(0,0,(progressBgView.frame.size.width*percentage)/100,progressBgView.frame.size.height)];

    } completion:^(BOOL finished) {
    }];
}

 - (void)setProgressBgColor:(UIColor *)color {

    progressBgView.backgroundColor = color;
 }

 - (void)setProgressBarColor:(UIColor *)color {

    progressBarView.backgroundColor = color;
 }

 @end

#!/bin/bash cat > pl.gp <<EOF ... CONTENTS ... EOF 脚本的结果会生成一个shell文件,其中包含pl.gp符合之前的所有文本。有没有人帮我理解shell强大的重定向用法?

1 个答案:

答案 0 :(得分:1)

这称为heredoc

<<EOF到以下EOF令牌的所有内容都会在其stdin上输入cat进程。 cat(就其性质而言)将通过stdout重定向(>运算符)将其转储到指定文件中