-
Notifications
You must be signed in to change notification settings - Fork 2
/
pipes.sh
39 lines (30 loc) · 953 Bytes
/
pipes.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# setting directory of this file
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
example_id="$1"
if [[ "${example_id}" == "1" ]]; then
cat "$SCRIPT_DIR/docker_images.output"
exit
fi
if [[ "${example_id}" == "2" ]]; then
cat "$SCRIPT_DIR/docker_images.output" | grep '3 months ago'
exit
fi
if [[ "${example_id}" == "3" ]]; then
cat "$SCRIPT_DIR/docker_images.output" | grep '3 months ago' | cut -d ' ' -f1
exit
fi
if [[ "${example_id}" == "4" ]]; then
cat "$SCRIPT_DIR/docker_images.output" | grep '3 months ago' | cut -d ' ' -f1 | sort -u
exit
fi
if [[ "${example_id}" == "5" ]]; then
# we don't need cat. this is better
grep '3 months ago' < "$SCRIPT_DIR/docker_images.output" | cut -d ' ' -f1 | sort -u
exit
fi
if [[ "${example_id}" == "6" ]]; then
# The best
grep '3 months ago' "$SCRIPT_DIR/docker_images.output" | cut -d ' ' -f1 | sort -u
exit
fi