Commit 7ce675b8 authored by mohamadbashar.disoki's avatar mohamadbashar.disoki

Add Readme.md

parent 30e6a5be
# Executive program
A shell executable program to determine the number of files within a folder specified by the user. It tests whether the number of files is less than
10 and prints the file names on the original output. If the number is greater than that, it writes the file names within a file in the same folder
called numfiles . The name of the folder to be tested is entered by the user .
Example of implementation :
./shell.sh folder
#A shell executable program to determine the number of files within a folder specified by the user. It tests whether the number of files is less than 10 and prints
# the file names on the original output. If the number is greater than that, it writes the file names within a file in the same folder called numfiles.
#program name : shell.sh
#!/bin/bash
directory=$1 # the folder you search for
Number_of_files=0
for file in "$directory"/*; do
if [ -f "$file" ]; then
Number_of_files=$((Number_of_files + 1))
fi
done
echo "Number of file in this folder = $Number_of_files"
if [ $Number_of_files -lt 10 ]; then
for file in "$directory"/*
do
if [ -f "$file" ]; then
echo "$(basename "$file")"
fi
done
else
for file in "$directory"/*
do
if [ -f $file ]; then
echo "$(basename "$file")" >> numfiles
fi
done
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment