Artificial intelligent assistant

What is the bash equivalent of the where cmdlet? The where cmdlet is something I use in PS quite often- its very convenient. If I want to get all files with a name starting with "test" I would do this: ls | ?{$_.name -like 'test*'} What is an equally terse way a nix admin would do this in bash? Bash is text not object based obviously so the command would probably be something like: ls | ?{<column#> -like 'test*'} I'm not asking about the ls command (`ls test*` would work, but that's command specific) I'm looking for a terse bash equivalent of how to pipe output through filters like this.

This will return only the files that start with "test":


ls | grep '^test'


**More examples** :

That will return only lines which contain the word "test". I am using ls -al" instead of "ls" alone to have a 1 line per record result:


ls -al | grep "test"


This would return any line containing test or word2:


ls -al | grep "test\|word2"


This would return any line not containing the string "test":


ls -al | grep -v "test"


If you really want to go by column, you can do like that:


ls -al | awk '$9 ~ /^test/'


Where $9 would mean column #9 which refers to the filename on my Debian machine, and the following regexp says that it starts with "test". awk separates columns by any run of spaces and/or tabs and/or newlines is treated as a field separator.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy fad1d56fc74c059ae200a798b56d022a