bash : recursive listing of all files problem

Posted by Michael Mao on Stack Overflow See other posts from Stack Overflow or by Michael Mao
Published on 2010-04-14T03:49:00Z Indexed on 2010/04/14 3:53 UTC
Read the original article Hit count: 342

Filed under:
|

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)

© Stack Overflow or respective owner

Related posts about bash

Related posts about homework