I'm trying to write a bash script that allows the user to pass a directory path using wildcards.
For example,
bash show_files.sh *
Run Code Online (Sandbox Code Playgroud)
when executed within this directory
drw-r--r-- 2 root root 4.0K Sep 18 11:33 dir_a
-rw-r--r-- 1 root root 223 Sep 18 11:33 file_b.txt
-rw-rw-r-- 1 root root 106 Oct 18 15:48 file_c.sql
Run Code Online (Sandbox Code Playgroud)
would output:
dir_a
file_b.txt
file_c.sql
Run Code Online (Sandbox Code Playgroud)
The way it is right now, it outputs:
dir_a
Run Code Online (Sandbox Code Playgroud)
contents of show_files.sh
:
#!/bin/bash
dirs="$1"
for dir in $dirs
do …
Run Code Online (Sandbox Code Playgroud)