Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list files/directories only in fishshell?

Tags:

fish

In fish:

for x in *
   echo $x
end

The * here includes all directories and files, how to list files(or directories) only?

like image 860
Freewind Avatar asked May 14 '16 04:05

Freewind


People also ask

How do I list files in a directory in flutter?

To list all the files or folders, you have to use flutter_file_manager, path, and path_provider_ex flutter package. Add the following lines in your pubspec. yaml file to add this package in your dependency. Add read / write permissions in your android/app/src/main/AndroidManifest.

Where is the fish shell config file?

fish files in ~/. config/fish/conf. d/ . See Configuration Files for the details.

How do I run a fish shell script?

To be able to run fish scripts from your terminal, you have to do two things. Add the following shebang line to the top of your script file: #!/usr/bin/env fish . Mark the file as executable using the following command: chmod +x <YOUR_FISH_SCRIPT_FILENAME> .


1 Answers

fish does not have lots of fancy globbing syntax. However, directories can be iterated like so:

for x in */
    echo $x
end

For files, or more sophisticated checks, you can use test:

for x in *
    if test -f $x
        echo $x
    end
end

or find:

for x in find . -type f -maxdepth 1
    echo $x
end
like image 176
ridiculous_fish Avatar answered Jan 18 '23 15:01

ridiculous_fish