Advertisement
Jobjob

tplinux2

Dec 20th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.14 KB | None | 0 0
  1. 2.2)
  2.  
  3. 1)$ find /usr -type f -exec cat {} \; | wc -l > res.txt &
  4.   $ kill -stop -groupprocessnum
  5.   $ kill -cont -groupprocessnum
  6.  
  7. 2)$ ps fUosms12
  8.  
  9. 3) père : bash
  10.    grandpère : sshd osms12@pts/12
  11.  
  12. 4) OK
  13.  
  14. 5) find /usr -type d -print | tee res.txt | wc -l
  15.  
  16. 6) grep --color -E "^.*home.*$" /etc/* | more
  17.  
  18. 7)$ tar zcf rep1.tgz rep1
  19.   $ tar zxf rep1.tgz
  20.  
  21. 8) OK
  22.  
  23. 9) ### envoyer ###
  24.    cat rep1.tgz > /tmp/jannouletube
  25.  
  26.    ### recevoir ###
  27.    tar -zxf /tmp/jannouletube
  28.  
  29. 10)
  30.  
  31. ### Code ###
  32.  
  33.     #include <stdio.h>
  34.  
  35.     int fibo();
  36.  
  37.     int main(){
  38.         int j = 0;
  39.         while(j < 0xFFFFFFFF){
  40.             int a = fibo(10);
  41.             j++;
  42.         }
  43.         j = 0;
  44.         while(j < 0xFFFFFFFF){
  45.             int a = fibo(10);
  46.             j++;
  47.         }
  48.         j = 0;
  49.         while(j < 0xFFFFFFFF){
  50.             int a = fibo(10);
  51.             j++;
  52.         }
  53.         j = 0;
  54.         while(j < 0xFFFFFFFF){
  55.             int a = fibo(10);
  56.             j++;
  57.         }
  58.     }
  59.  
  60.     int fibo(int n){
  61.         int x = 1;
  62.         int y = 1;
  63.         if(n <= 2) return x;
  64.         else{
  65.             int i = 3;
  66.             while(i <= n){
  67.                 int temp = x + y;
  68.                 x = y;
  69.                 y = temp;
  70.                 i++;
  71.             }
  72.             return y;
  73.         }
  74.     }
  75.  
  76. ############
  77.  
  78. 12)
  79.  
  80. ### Code ###
  81.  
  82.     #include <stdio.h>
  83.     #include <sys/types.h>
  84.     #include <sys/unistd.h>
  85.     #include <sys/wait.h>
  86.  
  87.     int fibo(int n);
  88.  
  89.     int main(){
  90.         int pid = fork();
  91.         if(pid == 0) { // fils
  92.             printf("Start fils.\n");
  93.             int j = 0;
  94.             while(j < 0xFFF){
  95.                 int a = fibo(10);
  96.                 j++;
  97.             }
  98.             printf("Fin fils.\n");
  99.             sleep(1);
  100.         } else { // père
  101.             printf("Start père.\n");
  102.             wait(&pid);
  103.             printf("Fin père.\n");
  104.         }
  105.  
  106.     }
  107.  
  108.     int fibo(int n){
  109.         int x = 1;
  110.         int y = 1;
  111.         if(n <= 2) return x;
  112.         else{
  113.             int i = 3;
  114.             while(i <= n){
  115.                 int temp = x + y;
  116.                 x = y;
  117.                 y = temp;
  118.                 i++;
  119.             }
  120.             return y;
  121.         }
  122.     }
  123.  
  124. ############
  125.    
  126.    $ ps fU osms12
  127.  
  128. 13) $ find / -name "bash*" |& less           (|& = toutes les sorties)
  129.  
  130. 14) find / -name "bash*" 2>&1 | less         (on redirige la sortied'erreur standard dans la sortie standard et on pipe vers less)
  131.  
  132. 15) bash1$ mkfifo cmdtube
  133.    bash1$ cat > cmdtube
  134.    bash2$ exec < cmdtube
  135.    bash1$ *entrer commandes*
  136.  
  137. 16) bash1$ cat > pipe
  138.     bash2$ exec < pipe >/dev/pts/9
  139.     bash1$ *entrer commandes*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement