-
Notifications
You must be signed in to change notification settings - Fork 0
Done module-bash #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/bash | ||
| if [ -z $1 ]; | ||
| then | ||
| echo "Hello, World!" | ||
| else | ||
| echo "Hello, $1!" | ||
| fi | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/bash | ||
|
|
||
| for files in "$@" | ||
| do | ||
| output=$(ls -R | grep $files) | ||
| if [[ $? -eq 0 ]] | ||
| then | ||
| echo $output | tr ' ' '\n' | ||
| else | ||
| echo the searched PATH is unexisting | ||
| fi | ||
| done | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2 existing paths 2 existing FILES tests are failed
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The outputs are identical, though don't need to do anything |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/bin/bash | ||
|
|
||
|
|
||
| if [[ -r $1 ]] | ||
| then | ||
| arguments=($2 $3 $4) | ||
| for arg in ${arguments[*]} | ||
| do | ||
| echo $arg $(grep -c $arg $1 ) | ||
| grep -n $arg $1 | cut -f1 -d":" | ||
|
|
||
| done | ||
| exit 0 | ||
| else | ||
| exit 1 | ||
| fi | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. approved |
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/bash | ||
| path=$2 | ||
| pattern=$1 | ||
| if [[ -z $pattern || -z $path ]] | ||
| then | ||
| exit 1 | ||
| else | ||
| files=$(find $2) | ||
| basename $files | ||
| grep -n $pattern $files | cut -f1 -d":" | ||
| exit 0 | ||
| fi | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No args and Without first arg tests are failed
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test is wrong, need to update!! |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/bin/bash | ||
|
|
||
|
|
||
| function sum(){ | ||
| evenresult=0 | ||
| oddresult=0 | ||
| for nums in $@ | ||
| do | ||
| if [[ $(($nums%2)) -eq 0 ]] | ||
| then | ||
| evenresult=$(($evenresult+$nums)) | ||
| else | ||
| oddresult=$(($oddresult+$nums)) | ||
| fi | ||
| done | ||
| result=$(($evenresult+$oddresult)) | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| case $1 in | ||
| -e) | ||
| sum ${@:2} && echo $evenresult | ||
| exit 0 | ||
| ;; | ||
| -o) | ||
| sum ${@:2} && echo $oddresult | ||
| exit 0 | ||
| ;; | ||
| -s) | ||
| sum ${@:2} && echo $result | ||
| exit 0 | ||
| ;; | ||
| -m) | ||
| sum ${@:2} && echo $(( $result / $(($#-1)) )) | ||
| exit 0 | ||
| esac | ||
| echo "Error.." | ||
| exit 1 | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two flags input test not passed
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed this one too |
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #!/bin/bash | ||
|
|
||
| function map(){ | ||
|
|
||
| for args in ${@:2} | ||
| do | ||
| eval $1 $args | ||
| done | ||
|
|
||
|
|
||
| } | ||
|
|
||
| map ${@} | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. approved |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
|
|
||
|
|
||
| if [[ -z $1 ]] | ||
| then | ||
| exit 1 | ||
| else | ||
| head -$1 resourses/surnames.txt | grep -v 'Q-Chem' | sed 's/-//;s/.$//' | ||
| exit 0 | ||
| fi | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test on 0 lines returns error and Test on 2 lines return empty string are failed
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed tests and ex07.sh |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/bin/bash | ||
| nums=( zeroes, ones, twoes, threes, fours, fives, sixs, sevens, eights, nines) | ||
|
|
||
|
|
||
| if [[ $# -gt 1 || $# -lt 1 ]] | ||
| then | ||
| echo "Error.." | ||
| exit 1 | ||
| fi | ||
|
|
||
|
|
||
|
|
||
| for i in {0..9} | ||
| do | ||
| arr[$i]=$(grep -o $i $1 | wc -l) | ||
| result+=' '${arr[$i]}' '${nums[$i]} | ||
| done | ||
| echo $result | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All tests except first one are failed, fixed test is here https://github.com/vpetrusenko/module-bash/pull/4/files#diff-3e35ef4d05c4325d58bedc87bb4e27eb
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed this one too |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/bash | ||
|
|
||
| case $1 in | ||
| -u) | ||
| grep "https://" $2 | ||
| ;; | ||
| -e) | ||
| grep '^[a-zA-Z0-9]\+@[a-zA-Z0-9]\+\.[a-z]\{2,\}' $2 | ||
| ;; | ||
| --url) | ||
| grep "https://" $2 | ||
| ;; | ||
| --email) | ||
| grep '^[a-zA-Z0-9]\+@[a-zA-Z0-9]\+\.[a-z]\{2,\}' $2 | ||
| ;; | ||
|
|
||
| esac | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. approved |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/bash | ||
|
|
||
|
|
||
|
|
||
| if [[ -r $1 ]] | ||
| then | ||
| echo $(awk 'END{print NR}' $1) $1 | ||
| exit 0 | ||
| fi | ||
| exit 1 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with directory and with 2 files tests are failed |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved