next up previous
Next: Grupowanie poleceń unixowskich z Up: wyklad6 Previous: wyklad6

Operacje przekierowywania

  1. Operator ``$>$''.

    [adam@etoh ~]$ more flagg
    Flagg's law of communication:
    When all other means of communication fail, try words.
    
    [adam@etoh ~]$ more veilind 
    Veilind's law of experimentation:
    (1) If reproducibility may be a problem, conduct the test only once.
    (2) If a straight line fit is required, obtain only two data points.
    
    [adam@etoh ~]$ cat flagg veilind > sentencje
    
    [adam@etoh ~]$ more sentencje 
    Flagg's law of communication:
    When all other means of communication fail, try words.
    Veilind's law of experimentation:
    (1) If reproducibility may be a problem, conduct the test only once.
    (2) If a straight line fit is required, obtain only two data points.
    

    Operator ``$>$'' niszczy pierwotną zawartość pliku; można się przed tym zabezpieczyć ustawiając zmienną noclobber:

    [adam@etoh ~]$ cat veilind > sentencje 
    
    [adam@etoh ~]$ more sentencje 
    Veilind's law of experimentation:
    (1) If reproducibility may be a problem, conduct the test only once.
    (2) If a straight line fit is required, obtain only two data points.
    
    [adam@etoh ~]$ set noclobber
    
    [adam@etoh ~]$ cat veilind > sentencje 
    sentencje: File exists.
    

  2. Operator dołączania ``$>>$''.

    [adam@etoh ~]$ cat flagg >> sentencje
    
    [adam@etoh ~]$ more sentencje 
    Veilind's law of experimentation:
    (1) If reproducibility may be a problem, conduct the test only once.
    (2) If a straight line fit is required, obtain only two data points.
    Flagg's law of communication:
    When all other means of communication fail, try words.
    

  3. Operator przekierowywania wyników działania polecenia oraz komunikatów systemowych ``$>\&$'' (może też być ``$>>\&$''):

    [adam@etoh ~]$ cat flag veilind > sentencje
    cat: flag: No such file or directory
    
    [adam@etoh ~]$ more sentencje
    Veilind's law of experimentation:
    (1) If reproducibility may be a problem, conduct the test only once.
    (2) If a straight line fit is required, obtain only two data points.
    
    [adam@etoh ~]$ cat flag veilind >& sentencje
    
    [adam@etoh ~]$ more sentencje
    cat: flag: No such file or directory
    Veilind's law of experimentation:
    (1) If reproducibility may be a problem, conduct the test only once.
    (2) If a straight line fit is required, obtain only two data points.
    

  4. Operator ``$<$'' przekierowania danych z pliku do programu.

    [adam@etoh ~]$ more warning
    Life is cruel, brutal, plugav and full of zasadzkas.
    
    - Winnie the Pooh
    
    [adam@etoh ~]$ spell < warning
    plugav
    zasadzkas
    



Adam Liwo 2002-03-07