Ticker

6/recent/ticker-posts

Shell Scripting Tutorial for Beginners 20 - FOR loop to execute commands



#!/bin/bash
# for loops

echo "all the files in directory--------"
for item in *
do
if [ -f $item ]
then
echo $item
fi
done

echo
echo "all the directory in directory--------"
for item in *
do
if [ -d $item ]
then
echo $item
fi
done
echo
echo "execute list of commands--------"
for command in ls pwd date
do
echo "command name -> $command"
$command
done

إرسال تعليق

0 تعليقات