bash : recursive listing of all files problem
- by Michael Mao
Run a recursive listing of all the
files in /var/log and redirect
standard output to a file called
lsout.txt in your home directory.
Complete this question WITHOUT leaving
your home directory.
An: ls -R /var/log/
/home/bqiu/lsout.txt
I reckon the above bash command is not correct.
This is what I've got so far:
$ ls -1R
.:
cal.sh
cokemachine.sh
dir
sort
test.sh
./dir:
afile.txt
file
subdir
./dir/subdir:
$ ls -R | sed s/^.*://g
cal.sh
cokemachine.sh
dir
sort
test.sh
afile.txt
file
subdir
But this still leaves all directory/sub-directory names (dir and subdir), plus a couple of empty newlines
How could I get the correct result without using Perl or awk? Preferably using only basic bash commands(this is just because Perl and awk is out of assessment scope)