-
Notifications
You must be signed in to change notification settings - Fork 0
Bash completed #4
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
a0eab57
cb2fc85
1a07a25
42fefa8
3a7c3c9
07cd27a
d9dd5fd
912572c
970f943
8e23c90
1164432
d429e8d
22557be
932ad0f
4125688
7d14fc2
f7686d3
9e4761a
cc08a85
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,6 @@ | ||
| #!/bin/bash | ||
| if ! [ -z $1 ]; then | ||
| echo "Hello, $1!" | ||
| else | ||
| echo "Hello, World!" | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
| str=$( echo $1 | tr " " "\n" ) | ||
| for i in $str | ||
| do | ||
| ls -R | grep -Fi $i || echo "the searched PATH is unexisting" | ||
| 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. approved |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/bash | ||
|
|
||
| if [ -z $1 ]; then | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! [ -z $1 ]; then | ||
| touch .f | ||
| for i in "${@:2}" | ||
| do | ||
| grep -in $i $1 > .f | ||
| n=$(cat .f | wc -l) | ||
| echo "$i $n" | ||
| awk -F: '{print $1}' .f | ||
| done | ||
| rm .f | ||
| 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. Please do it without file creation |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/bin/bash | ||
|
|
||
| if [ -z $1 ] || [ -z $2 ]; then | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo $2 | cut -d'/' -f 2 | ||
| grep -in $1 $2 | cut -d : -f 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. No args and Without first arg tests are failed |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/bin/bash | ||
|
|
||
| if [ -z $2 ]; then | ||
| echo "0" | ||
| exit 0 | ||
| fi | ||
|
|
||
| summ=0 | ||
|
|
||
| for i in $@ | ||
| do | ||
| if [ "$1" == "-s" ]; then | ||
| summ=$(echo "$summ + $i" | bc) | ||
| elif [ "$1" == "-m" ]; then | ||
| summ=$(echo "$summ + $i" | bc) | ||
| elif [ "$1" == "-e" ]; then | ||
| [ $((i%2)) -eq 0 ] && summ=$(echo "$summ + $i" | bc) | ||
| elif [ "$1" == "-o" ]; then | ||
| [ $((i%2)) -ne 0 ] && summ=$(echo "$summ + $i" | bc) | ||
| else | ||
| echo "Error.." | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| if [ "$1" == "-m" ]; then | ||
| shift 1 | ||
| summ=$(echo $(( "$summ / $#" ))) | ||
| fi | ||
|
|
||
| echo "$summ" | ||
|
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 are failed, also please rewrite it with switch statement |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/bin/bash | ||
| map() { | ||
| arg=$1 | ||
| shift | ||
| for i in "$@" | ||
| do | ||
| shift | ||
| eval "$arg $i" | ||
| done | ||
| } | ||
|
|
||
| if [ $1 ]; then | ||
| map $@ | ||
| 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,13 @@ | ||
| #!/bin/bash | ||
|
|
||
| if [ -z "$1" ] || [ "$1" -eq 0 ]; then | ||
| exit 1 | ||
| fi | ||
|
|
||
| answer=$(head "-$1" resourses/surnames.txt | grep -v 'Q-Chem' | sed "s/\.//g ; s/\-//g" | cat ) | ||
|
|
||
| if [[ $answer ]]; then | ||
| echo "$answer" | ||
| else | ||
| echo '' | ||
| 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,21 @@ | ||
| #!/bin/bash | ||
|
|
||
| if [ -z $1 ] || [ $# -gt 1 ] ; then | ||
| echo "Too many(few) arguments" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -f "$1" ]; then | ||
| echo "Error.." | ||
| exit 1 | ||
| fi | ||
|
|
||
| answer="" | ||
| words=( zeroes ones twoes threes fours fives sixs sevens eights nines ) | ||
| wlen=${#words[@]} | ||
| for (( i=0; i<${wlen}; i++ )) | ||
| do | ||
| answer+=$(grep -o "$i" $1 | wc -l) | ||
| answer+=" ${words[$i]}, " | ||
| done | ||
| echo "$answer" | sed 's/..$//' | ||
|
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,13 @@ | ||
| #!/bin/bash | ||
|
|
||
| if [ -z $1 ] || [ -z $2 ]; then | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$1" = "-u" ] || [ "$1" = "--url" ]; then | ||
| grep -Po '(^|\t)https:[A-Za-z0-9\/\.]+' $2 | ||
| elif [ "$1" = "-e" ] || [ "$1" = "--email" ]; then | ||
| grep -Po '(^|\t)[A-Za-z0-9\.]+@[A-Za-z0-9\.]+\.[A-Za-z0-9\.]+' $2 | ||
| 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,10 @@ | ||
| #!/bin/bash | ||
|
|
||
| if [ ! -f "$1" ];then | ||
| exit 1 | ||
| fi | ||
|
|
||
| for i in $@ | ||
| do | ||
| echo "$(awk 'END{print NR}' $i) $i" | ||
| 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. approved |
||
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