I know there is a nice Linux program called find
, which used as
find /home/user -name ".txt"
will print all the files with .txt
extension with their relative path
How can I achieve the same using ls
, grep
and possibly awk
?
I tried listing all files in directory and its subdirectories recursively using
ls -LR1
but have no idea how to parse it using grep
.
Any advice would be greatly appraciated.
You can do this with bash4 and zsh :
shopt -s globstar # required if not enabled with bash4
printf '%s\n' **/*.txt
But don't trust anyone finding a solution with ls
+ awk
, not the good way to achieve this with robustness