Advertisement
Wyvern67

PSE TP04

Oct 12th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.68 KB | None | 0 0
  1. Ex 1.
  2. 1
  3.  
  4. 2.  ls: cannot access bidule: No such file or directory
  5.  
  6. 3.  ls: cannot access bidule: No such file or directory
  7.     hello
  8.  
  9. 4.  argypriou@turing:~/PSE/TP04$ touch bidule
  10.     argypriou@turing:~/PSE/TP04$ ls bidule && echo hello
  11.     bidule
  12.     hello
  13.  
  14. 6.  argypriou@turing:~/PSE/TP04$ touch test1 test2 test3
  15.     argypriou@turing:~/PSE/TP04$ ls
  16.     argypriou@turing:~/PSE/TP04$ wc -w
  17.     6
  18.  
  19. 7.  argypriou@turing:~/PSE/TP04$ ls | wc -w
  20.  
  21. 8.  argypriou@turing:~/PSE/TP04$ ls | sed s/test/bidule/
  22.  
  23. Ex 2.
  24. 1.  Je rentre "nedit &" dans chacun des terminaux
  25. 2.  la commande "ps" tout court ne liste que les programmes du terminal lui-même
  26. 3a) ps -u argypriou | grep nedit
  27.  b) ps -u argypriou | grep nedit | tr -s " "
  28.  c) ps -u argypriou | grep nedit | tr -s " " | cut -d " " -f1
  29.  e) kill `ps -u argypriou | grep nedit | tr -s " " | cut -d " " -f1`
  30.  f) nedit & nedit & nedit & nedit &
  31.     pkill nedit &2> /dev/null
  32.  
  33.  
  34.  
  35.  
  36.  
  37. Ex 3.
  38. 1.
  39. |Script|
  40.     #!/bin/sh
  41.  
  42.     if [ $# -lt 1 ]
  43.         then echo "usage: $0 cmd_1 [cmd_2] ... [cmd_n]"
  44.         exit 1
  45.     fi
  46.  
  47.     for PARAM in $*
  48.     do
  49.         ps -C $PARAM
  50.     done
  51.     exit 0
  52.  
  53. 2.
  54. |Script|
  55.     #!/bin/sh
  56.  
  57.     if [ $# -lt 1 ]
  58.         then echo "usage: $0 cmd_1 [cmd_2] ... [cmd_n]"
  59.         exit 1
  60.     fi
  61.  
  62.     PARAM=$1
  63.  
  64.     for i in $*;do
  65.         PARAM=$PARAM,$i
  66.     done
  67.     echo $PARAM
  68.  
  69.     ps -C $PARAM
  70.     exit 0
  71.  
  72.  
  73. 3
  74. |Script|
  75.     #!/bin/sh
  76.  
  77.     if [ $# -lt 1 ]
  78.         then echo "usage: $0 cmd_1 [cmd_2] ... [cmd_n]"
  79.         exit 1
  80.     fi
  81.  
  82.     PARAM=$(echo $* | tr " " ",")
  83.  
  84.     ps -C $PARAM
  85.     exit 0
  86.  
  87. 4.
  88. |Script|
  89.     #!/bin/sh
  90.  
  91.     if [ $# -lt 1 ]
  92.         then echo "usage: $0 cmd_1 [cmd_2] ... [cmd_n]"
  93.         exit 1
  94.     fi
  95.  
  96.  
  97.     HEADER=""
  98.     while [ $# -gt 0 ]
  99.     do
  100.         ps -C $1 $HEADER
  101.         shift
  102.         HEADER="--no-header"
  103.     done
  104.     exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement