1

I know what ls folder/ and ls *abc* do in linux. I want to filter out some files in a specific folder.

I tried this: ls folder/ *abc but it does not return correct values.

Any idea?

Thanks

2 Answers 2

1

Try using find.

find folder/ -d 1 -name '*abc'

folder/: Path to search

-d 1: Only search one level down. This prevents it from searching all subdirectories below the folder you're looking for. Remove this if you want that behavior.

-name '*abc': The pattern to search for.

More information can be gotten with man find.

0

As stated earlier, find might be a better option, but to do what you want using ls, try filtering using grep:

user@host:/etc$ ls homeassistant | grep config
config
configuration.yaml
configuration_bak.yaml
dockerconfig
dockerconfig.bak

.. As this returns all files and folders containing the word "config" from the directory homeassistant.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .