Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ex01/hello_world.sh
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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

12 changes: 12 additions & 0 deletions ex02/ex02.sh
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 existing paths 2 existing FILES tests are failed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The outputs are identical, though don't need to do anything

22 changes: 22 additions & 0 deletions ex03/ex03.sh
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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved






12 changes: 12 additions & 0 deletions ex04/ex04.sh
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No args and Without first arg tests are failed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is wrong, need to update!!

45 changes: 45 additions & 0 deletions ex05/ex05.sh
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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two flags input test not passed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed this one too




13 changes: 13 additions & 0 deletions ex06/ex06.sh
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 ${@}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

10 changes: 10 additions & 0 deletions ex07/ex07.sh
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
Copy link
Owner

Choose a reason for hiding this comment

The 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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed tests and ex07.sh

18 changes: 18 additions & 0 deletions ex08/ex08.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
Copy link
Owner

@vpetrusenko vpetrusenko Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed this one too

17 changes: 17 additions & 0 deletions ex09/ex09.sh
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

10 changes: 10 additions & 0 deletions ex10/ex10.sh
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with directory and with 2 files tests are failed