I want to go to a directory with using filter
For example there is a file named this-is-awsome
ls | grep this-is-awsome | xargs cd
How can I go to a directory with filter?
I want to go to a directory with using filter
For example there is a file named this-is-awsome
ls | grep this-is-awsome | xargs cd
How can I go to a directory with filter?
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 find
):
cd "$(find -maxdepth 1 -type d -name '*this*')"
Yet another (maybe even better) solution if you're using Bash:
shopt -s nullglob
cd *this*/
This works for me:
>>pwd | xclip
>>cd `xclip -o`
alias z = 'export FZF_DEFAULT_COMMAND="/usr/bin/fdfind -t d -H -L -E .git -E dosdevices -E p_rsnapshot" && fzf | xclip && cd $(xclip -o)'
fzf | xclip && cd $(xclip -o)
could be replaced by fzf > tmp__ && cd $(cat tmp__) && rm tmp__
.
– John 9631
Oct 23 '20 at 21:20
When you have one file with "this", just use
cd *this*
/
in my globshopt -s nullglob
was necessary.