Need bash script to display files
#!/bin/bash
my_ls() {
# save current directory then cd to "$1"
pushd "$1" >/dev/null
# for each non-hidden (i.e. not starting with .) file/directory...
for file in * ; do
# print file/direcotry name if it really exists...
test -e "$file" && echo "$2$file"
# if directory, go down and list directory contents too
test -d "$file" && my_ls "$file" "$2 "
done
# restore directory
popd >/dev/null
}
my_ls
expected output:
file1
file2
info (directory)
data
stuff (directory)
input
output
scripts (directory)
doit
helper
testinput
jobs
results (directory)
bob
dave
mary