Convert this code to exclude multiple folders?

oslon

Member
Joined
Oct 15, 2023
Messages
40
Reaction score
6
Credits
424
# Script
Code:
#!/bin/bash
given_path=/home/techyman/glassfish4/glassfish/domains
excluded_folder=x
for each in $(ls $given_path); do
    if [ "$excluded_folder" = "$each" ]; then
        echo "This is x"
        continue
    else
        echo "this is not x"
        cd $given_path/$each/logs
        echo "This is $PWD"
    fi
done
# What it does
  • This goes to given path.
  • Does a listing by ls
  • If that ls equals to excluded folder, it'll skip it with that continue statement
  • Else it goes inside logs directory and does some actions.

I wrote this and I'm proud for it :D .
I feel like I need an array to make it of practical usage. So, wondering if I can get some hints and help here.
 

Staff online

Members online


Latest posts

Top