# # Copyright (c) 2021 Guy Baconniere. # ## How to use this Makefile # # cd git # mkdir ex01 # cd ex01 # make -f ../../Makefile ex01 # marvin = "\"\\\?\$$\*\'MaRViN\'\*\$$\?\\\"" clone: @git clone git@vogsphere.42lausanne.ch:vogsphere/intra-uuid-a2e8ee6f-787d-4ee8-9eb4-359821770152-3701046 git ex01: @rm -f print_groups.sh @printf "#!/bin/sh\n" > print_groups.sh @printf "id -Gn \$$FT_USER | tr ' ' ','\n" >> print_groups.sh @chmod +x print_groups.sh @FT_USER=daemon ./print_groups.sh | cat -e ex02: @rm -f find_sh.sh file?.sh @touch file1.sh file2.sh file3.sh @printf "#!/bin/sh\n" > find_sh.sh @printf "find . -type f -name '*.sh' -exec basename '{}' .sh \;\n" >> find_sh.sh @chmod +x ./find_sh.sh @./find_sh.sh | cat -e @rm -f file?.sh ex03: @rm -f count_files.sh file* @touch file{1..40} @printf "#!/bin/sh\n" > count_files.sh @printf "find . \( -type f -o -type d \) | wc -l | tr -d ' '\n" >> count_files.sh @chmod +x ./count_files.sh @./count_files.sh | cat -e @rm -f file* ex04: @rm -f MAC.sh @printf "#!/bin/sh\n" > MAC.sh @printf "ifconfig | grep -oE 'ether .*' | cut -c7-23\n" >> MAC.sh @chmod +x ./MAC.sh @./MAC.sh | cat -e ex05: @rm -f -- *MaRV* @printf "42" > "$(marvin)" @touch -t 10021221.00 "$(marvin)" @chmod 0614 "$(marvin)" @ls -lRA *MaRV* | cat -e ex06: @rm -f skip.sh file* @touch file{1..8} @printf "#!/bin/sh\n" > skip.sh @printf "ls -l | awk '{ if ((NR + 1) %% 2 == 0) print \$$0 }'\n" >> skip.sh @chmod +x ./skip.sh @./skip.sh | cat -e @rm -f file* ex07: @rm -f r_dwssap.sh @printf "#!/bin/sh\n" > r_dwssap.sh @printf "grep -v '^#' /etc/passwd | awk -F ':' '/^FT_LINE1/,/^FT_LINE2/ { n++; login=\$$1; rev=\"rev <<<\"login; rev | getline revlogin; close(rev); print ((n > 1) && ((n+1) %% 2 == 0))? revlogin:login }' | sort -rh | tr '\\\\n' ' ' | sed 's/ $$/./; s/ /, /g;'\n" >> r_dwssap.sh @chmod +x ./r_dwssap.sh @./r_dwssap.sh | cat -e ex08: @rm -f add_chelou.sh @printf "#!/bin/sh\n" > add_chelou.sh @printf "echo Trop chelou de jouer avec tr et de jouer cet escape game.\n" >> add_chelou.sh @chmod +x ./add_chelou.sh @./add_chelou.sh | cat -e all: clone