I want to go to a directory with using filter
For example there is a file named
ls | grep this-is-awsome | xargs cd
How can I go to a directory with filter?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Salton's comment explains the problem. Here are some solutions:
cd "$(ls | grep this)"
This is probably not so good, with all the usual caveats about parsing the output of
ls applying to it.
A slightly better version (assumes GNU
cd "$(find -maxdepth 1 -type d -name '*this*')"
Yet another (maybe even better) solution if you're using Bash:
shopt -s nullglob cd *this*/