illtbagu
asked on
Linux Bash Complex Variable
I would like to store a list of files as a variable using the if statement. What I have below works but its sloppy, is there a better way to do this.
#!/bin/sh
variable=
for file in /directory_path/*.txt; do
if [ -w $file ]; then file2=$file
echo $file2
fi
done
echo $variable
#!/bin/sh
variable=
for file in /directory_path/*.txt; do
if [ -w $file ]; then file2=$file
echo $file2
fi
done
echo $variable
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window