From f4973c5e84dc24c12d8393d7de8a4e482d0628d3 Mon Sep 17 00:00:00 2001 From: Alik Beckles <ab5e20@soton.ac.uk> Date: Sun, 13 Feb 2022 17:18:12 +0000 Subject: [PATCH] A script that uses for loops and the wc command which reads the number of lines --- loop.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 loop.sh diff --git a/loop.sh b/loop.sh new file mode 100755 index 0000000..c485039 --- /dev/null +++ b/loop.sh @@ -0,0 +1,14 @@ +#!/bin/bash +#Basic for loop +for i in {1..10} +do + echo hello $i +done + +#For loop for files +for file in ./* +do + numLines=$(wc -l < $file) + echo The file $file contains $numLines lines of text +done + -- GitLab