From d077e4967d0727e4144da3fd47d82a1eafcd280b Mon Sep 17 00:00:00 2001 From: moha880 <81478561+moha880@users.noreply.github.com> Date: Wed, 26 Jul 2023 21:18:17 +0300 Subject: [PATCH] mohamed ibrahim --- student_solution.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/student_solution.sh b/student_solution.sh index 8b13789..9ef9567 100644 --- a/student_solution.sh +++ b/student_solution.sh @@ -1 +1,23 @@ +#!/bin/bash + +ENTEREDPATH=$1 +for f in ${ENTEREDPATH}/* ;do + #skip directories + if [ ! -f ${f} ] ;then + continue + else + #ectract the extensions + EXTENSION="${f##*.}" + #in case the file has no ectension the EXTENSION variable store the + #directory of the file so checking the length it will be known that the file is unknown + if [ ${#EXTENSION} -gt 7 ]; then + mkdir -p ${ENTEREDPATH}/WITHOUT + mv ${f} ${ENTEREDPATH}/WITHOUT + else + mkdir -p ${ENTEREDPATH}"/"${EXTENSION} + mv ${f} ${ENTEREDPATH}"/"${EXTENSION} + fi + fi +done +