Skip to content

Commit

Permalink
initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
gilcot committed May 29, 2017
0 parents commit 555691d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
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."

8 changes: 8 additions & 0 deletions get_comments
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-

5 changes: 5 additions & 0 deletions test0_txt
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

13 changes: 13 additions & 0 deletions test1_sh
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
4 changes: 4 additions & 0 deletions test1_txt
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

0 comments on commit 555691d

Please sign in to comment.