Commit a3217ff5 authored by mohamad.shahood's avatar mohamad.shahood

Executive program

parent b4bc0134
#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
#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