shell - Dont understand (Pipes) usage unix -
i studying 'operational systems' exams @ uni , having hard time understanding pipes usage (|). here example found on internet:
ps -ax | grep finder
use ps command list of processes running on system, , pass list grep search lines containing "finder". (usually, it'll find two: finder, , processes executing grep finder.)
what if first write ps -ax , @ next line grep finder ? wont have same result? why have pipe them together?
ps: bigginer @ unix shell commands , how works.
it's redirecting input , output.
if type ps -ax > processes, create file processes list of processes. redirecting output. data shown screen instead written file.
if type grep finder < processes, search file processes word finder. redirecting input.
pipe both. redirects output of command on left side , redirects input of command on right side.
$ ps -ax | grep finder is like
$ ps -ax > temp $ grep finder < temp except on 1 line no temp file delete.
Comments
Post a Comment