I'm learning Linux scripting and trying to set up a function that finds all files in the current directory. I know I could use ls but I'm wondering if there is a way to get the current directory as a command and pass it to an argument.
#!/bin/bash
check_file() {
for f in $1:
do
echo $f
done
}
check_file pwd
This just prints out pwd:, which obviously isn't it.
PWD
variable does exactly what you want.
So just replace pwd
with $PWD
and you are done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With