-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 555691d
Showing
5 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# doc4sh | ||
|
||
This a collection of scripts that could be a Ghist each. | ||
|
||
## `get_comments` | ||
|
||
During my _Unix_ course, this is one of the exercice I ask my students in | ||
in order to start playing with `grep`: | ||
"Using only grep, write a script that will extract from a given shell script, | ||
after checking the file argument, all comments that start at firsh column." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
# readable file requiered | ||
grep -q "" "$1" || exit 1 | ||
|
||
# extract comments | ||
grep '^#' "$1" | cut -c 2- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
make this file unreadable to all, | ||
but writable by user and it's group | ||
(so one can echo test into it...) | ||
> chmod 0220 test0_txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
# Shell script test | ||
############################ | ||
# 1. Ask for name | ||
printf "Who are you? " # 1.1 print question | ||
read name # 1.2 read answer | ||
# 2. Warm salutions | ||
printf "\nHello %s\n" "$name" # 2.1. say hello | ||
printf "\nI am %s\n" "$(uname -n)" # 2.2 introduce yourself | ||
printf "\nToday is %s\n\n" "$(date +%D)" # 2.3 a memorable day | ||
# 3 So shy | ||
sleep 15 # 3.1 nothing to say... | ||
echo See you # 3.2 say goodbye |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
make this text file readable by everyone | ||
> chmod 0664 test1_txt | ||
but it should have any hash sign somewhere | ||
> sed -i '/#/d' test1_txt |