How does a pipe work in Linux?

If you want to redirect the output of one program into the input of another, just use a simple pipeline: program1 arg arg | program2 arg arg If you want to save the output of program1 into a file and pipe it into program2, you can use tee(1): program1 arg arg | tee output-file | … Read more

running a command line containing Pipes and displaying result to STDOUT

Use a subprocess.PIPE, as explained in the subprocess docs section “Replacing shell pipeline”: import subprocess p1 = subprocess.Popen([“cat”, “file.log”], stdout=subprocess.PIPE) p2 = subprocess.Popen([“tail”, “-1”], stdin=p1.stdout, stdout=subprocess.PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output,err = p2.communicate() Or, using the sh module, piping becomes composition of functions: import sh output = sh.tail(sh.cat(‘file.log’), … Read more

How to allow html in return of angular2 pipe?

Use bindings to innerHTML or outerHTML to render already escaped html. For example <span [innerHTML]=”someString | toHtmlPipe”></span>. See this plunk: @Pipe({ name: ‘wrapBold’ }) class WrapBold { transform(content) { return `<b>${content}</b>`; } } @Component({ selector: ‘my-app’, pipes: [WrapBold], template: ` <div> Hello <span [outerHTML]=”content | wrapBold”></span> </div> ` }) export class App { constructor() { … Read more

Get exit code from subshell through the pipes

By using $() you are (effectively) creating a subshell. Thus the PIPESTATUS instance you need to look at is only available inside your subshell (i.e. inside the $()), since environment variables do not propagate from child to parent processes. You could do something like this: OUT=$( wget -q “http://budueba.com/net” | tee -a “file.txt”; exit ${PIPESTATUS[0]} … Read more

Filtering an array in angular2

There is no way to do that using a default pipe. Here is the list of supported pipes by default: https://github.com/angular/angular/blob/master/modules/angular2/src/common/pipes/common_pipes.ts. That said you can easily add a pipe for such use case: import {Injectable, Pipe} from ‘angular2/core’; @Pipe({ name: ‘myfilter’ }) @Injectable() export class MyFilterPipe implements PipeTransform { transform(items: any[], args: any[]): any { … Read more