1

I have a folder /home/Documents/myFolder and inside this folder there are lots other folders. I want to have a file list.txt which contains all the paths of the folders. I want the text file content like this:

 /home/Documents/myFolder/1234
 /home/Documents/myFolder/asd2
 /home/Documents/myFolder/asdawgf
 /home/Documents/myFolder/dawt
 .
 .
 .

I tried this one but it was not what I want ls > /home/Documents/myFolde/list.txt it just prints the folder names. I want the full paths.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
user667222
  • 179
  • 3
  • 16

2 Answers2

1

Use find listing all directories (-type d) and then sed the output to get the full path correct:

find . -type d | sed -n 's:^\./:/home/Documents/myFolder/:'p > /home/Documents/myFolder/list.txt
suspectus
  • 16,548
  • 8
  • 49
  • 57
0

you can use find:

find . > /home/Documents/myFolde/list.txt
Noor
  • 19,638
  • 38
  • 136
  • 254