Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ex 1.
- 1.
- 2. ls: cannot access bidule: No such file or directory
- 3. ls: cannot access bidule: No such file or directory
- hello
- 4. argypriou@turing:~/PSE/TP04$ touch bidule
- argypriou@turing:~/PSE/TP04$ ls bidule && echo hello
- bidule
- hello
- 6. argypriou@turing:~/PSE/TP04$ touch test1 test2 test3
- argypriou@turing:~/PSE/TP04$ ls
- argypriou@turing:~/PSE/TP04$ wc -w
- 6
- 7. argypriou@turing:~/PSE/TP04$ ls | wc -w
- 8. argypriou@turing:~/PSE/TP04$ ls | sed s/test/bidule/
- Ex 2.
- 1. Je rentre "nedit &" dans chacun des terminaux
- 2. la commande "ps" tout court ne liste que les programmes du terminal lui-même
- 3a) ps -u argypriou | grep nedit
- b) ps -u argypriou | grep nedit | tr -s " "
- c) ps -u argypriou | grep nedit | tr -s " " | cut -d " " -f1
- e) kill `ps -u argypriou | grep nedit | tr -s " " | cut -d " " -f1`
- f) nedit & nedit & nedit & nedit &
- pkill nedit &2> /dev/null
- Ex 3.
- 1.
- |Script|
- #!/bin/sh
- if [ $# -lt 1 ]
- then echo "usage: $0 cmd_1 [cmd_2] ... [cmd_n]"
- exit 1
- fi
- for PARAM in $*
- do
- ps -C $PARAM
- done
- exit 0
- 2.
- |Script|
- #!/bin/sh
- if [ $# -lt 1 ]
- then echo "usage: $0 cmd_1 [cmd_2] ... [cmd_n]"
- exit 1
- fi
- PARAM=$1
- for i in $*;do
- PARAM=$PARAM,$i
- done
- echo $PARAM
- ps -C $PARAM
- exit 0
- 3.
- |Script|
- #!/bin/sh
- if [ $# -lt 1 ]
- then echo "usage: $0 cmd_1 [cmd_2] ... [cmd_n]"
- exit 1
- fi
- PARAM=$(echo $* | tr " " ",")
- ps -C $PARAM
- exit 0
- 4.
- |Script|
- #!/bin/sh
- if [ $# -lt 1 ]
- then echo "usage: $0 cmd_1 [cmd_2] ... [cmd_n]"
- exit 1
- fi
- HEADER=""
- while [ $# -gt 0 ]
- do
- ps -C $1 $HEADER
- shift
- HEADER="--no-header"
- done
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement