List only files in the root directory

Let's say I have a file structure that looks like this:

|_ file1.txt
|_ file2.txt
    |_ subdir1
    |_ subdir2
    |_ subdir3

I want to list the contents of this structure, but I want to exclude everything, in all directories, except the stuff in the root. In this case, that would be file1.txt and file2.txt. I know I can use --exclude, but if I have lots of subdirectories, I would need many --exclude calls, unless there's a way to exclude everything at once.

After running whatever command it is, I expect to see only file1.txt and file2.txt because they're the only things in /

Easily solved.

Here are the listing commands depending on what info you want:

Use --max-depth 1 to limit these listing to 1 level (root)
(or another number if you want to go X levels down in the hierarchy)

I figured it would be something as simple as that. Thanks!

If you are using that for scripting then rclone lsf is what you want.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.