user2428207
user2428207

Reputation: 825

Shell script to write folder tree structure to file

I need a shell script that writes the tree structure (including all data in the folders) from a specific folder to a text/dat file.

So far I got this:

find . -type f|sed 's_\.\/__' > PATH/Input.dat

I dont want a "/" as the first char of the path.

This script works fine, but it returns ALL folder structures. I need something that returns only structures from a specific folder, like "Sales".

Upvotes: 1

Views: 965

Answers (1)

devnull
devnull

Reputation: 123518

I need something that returns only structures from a specific folder, like "Sales".

Specify the desired folder name. Say:

find Sales -type f | sed 's_\.\/__'
     ^^^^^

Saying find . ... would search in . (i.e. the current directory and subdirectories).

If you need to search more folders, say Purchase, specify those too:

find Sales Purchase -type f | sed 's_\.\/__'

Upvotes: 2

Related Questions