Jorge Lazo
asked on
Linux Bash Script - List file directories on hard drive
Hello all,
I am attempting to write a Linux bash script to read the file directory off an external drive. i would like to be able to pull a quick list of the file directories so that i can save them for future reference.
thank you in advance
I am attempting to write a Linux bash script to read the file directory off an external drive. i would like to be able to pull a quick list of the file directories so that i can save them for future reference.
thank you in advance
I'm guessing you mean contents of file directory.
So something like this...
So something like this...
for file in $dir/* ; do echo $file ; done
Maybe mention what "future use" might mean.
In a file, like Jorge suggested or to use later in a script as I suggested.
Give an exact description of what you'll use these for.
Also... occurs to me... you might be doing this because you have many files in a directory. Mention file count, if the count is large.
In a file, like Jorge suggested or to use later in a script as I suggested.
Give an exact description of what you'll use these for.
Also... occurs to me... you might be doing this because you have many files in a directory. Mention file count, if the count is large.
THe following will recurse through all directories on a disk. And show all files including hidden files.
ls -laR /mountpoint >/archive/directory/TheDis kName.list
another one might be:
find /mountpoint -ls >/archive/directory/TheDis kName.list
ls -laR /mountpoint >/archive/directory/TheDis
another one might be:
find /mountpoint -ls >/archive/directory/TheDis
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can also use PERL for this. The code will be far simpler + easier to read...
my $dir = "path-to-your-directory";
my @files = glob("$dir/*");
foreach my $file (@files) {
# do something here with $file
}
ASKER
i was able to use
Thank you everyone!
ls -LR /Volumes/Drive/> textfile.txt
Thank you everyone!
ASKER
Open in new window