Using bash in LInux

03/07/2022   Linux

Using bash in LInux

// runBash.sh
========================

#!/bin/bash
# ============ use variable
friend="Phong1"
echo hello, $friend
# ============ use read input
echo who are yoU?
read who
echo  hello, $who
# ============ use if
echo how old are you?
read age
if [ $age -gt 20 ]
then 
        echo You can drink
else
        echo you can NOT drink
fi
# ============ use for
FILES=/*
for file in $FILES
do
        echo $(basename $file)
done

Bài viết cùng chủ đề