shell - Bash Script for listing subdirectories and files in textfile -


i need script writes directory , subdirectory in text-file.

for example script lies in /mainfolder , in folder 4 other folders. each contains several files.

now script write path of each file in textfile.

subfolder1/file1.dat subfolder1/file2.dat subfolder2/file1.dat subfolder3/file1.dat subfolder4/file1.dat subfolder4/file2.dat 

important there no slash in front of listing.

use find command:

find mainfolder > outputfile 

and if want files listed, do

find mainfolder -type f > outputfile 

you can strip leading ./ if search current directory, %p format option:

find . -type f -printf '%p\n' > outputfile 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -