From 7319f80573b9c73156d379361787f03dad48f26d Mon Sep 17 00:00:00 2001 From: Alex Marginean <agm1g21@soton.ac.uk> Date: Mon, 14 Feb 2022 11:42:58 +0000 Subject: [PATCH] Completed Lab 2 --- Lab2/for.sh | 6 ++++++ Lab2/for2.sh | 7 +++++++ Lab2/hello.sh | 3 +++ Lab2/var.sh | 7 +++++++ Lab2/var2.sh | 7 +++++++ 5 files changed, 30 insertions(+) create mode 100755 Lab2/for.sh create mode 100755 Lab2/for2.sh create mode 100755 Lab2/hello.sh create mode 100755 Lab2/var.sh create mode 100755 Lab2/var2.sh diff --git a/Lab2/for.sh b/Lab2/for.sh new file mode 100755 index 0000000..01085c6 --- /dev/null +++ b/Lab2/for.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +for i in {1..10} +do + echo Hello $i +done diff --git a/Lab2/for2.sh b/Lab2/for2.sh new file mode 100755 index 0000000..598fcc7 --- /dev/null +++ b/Lab2/for2.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +for file in ./* +do + numLines=$(wc -l < $file) + echo The file $file contains $numLines lines of text +done diff --git a/Lab2/hello.sh b/Lab2/hello.sh new file mode 100755 index 0000000..485e2f6 --- /dev/null +++ b/Lab2/hello.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "Hello world!" diff --git a/Lab2/var.sh b/Lab2/var.sh new file mode 100755 index 0000000..b2a1433 --- /dev/null +++ b/Lab2/var.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +#Set a variable +exampleVariable=600 + +#Print out the result +echo The value of the variable is $exampleVariable diff --git a/Lab2/var2.sh b/Lab2/var2.sh new file mode 100755 index 0000000..e273414 --- /dev/null +++ b/Lab2/var2.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +#Set a variable +exampleVariable=$(./hello.sh) + +#Print out the result +echo The value of the variable is $exampleVariable -- GitLab