I have a little script that lists the directories in a given folder... Which works great. I can then type what number and it sets that given folder as my environment.

I'd like to create something similar that only lists directories matching a grep pattern. Is this possible? Say search for 20 and it will list shots 20, 200 etc

alias sl='cds ; printf  "Please select SHOT ENVIRONMENT:\n"
select d in */ ; do test -n "$d" && break; echo ">>> Invalid Selection"; done
cd "$d" && ss'

Any help? I'm quite new to this.

closed as unclear what you're asking by Sparhawk, telcoM, Jeff Schaller, slm Aug 11 at 16:30

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • are you looking something like ls $d*, where d->20 – SivaPrasath Aug 10 at 10:37
  • 4
    Your example is simple enough to accomplish with wildcards; when you say "grep pattern", that's a regular expression, which can match more complicated patterns than wildcards can. Can you expand your question with the types of patterns you're interested in? – Jeff Schaller Aug 10 at 11:13
  • 1
    You seem to be using a socket-statistics (ss) tool, did you intend to use ls? – ctrl-alt-delor Aug 10 at 11:35
  • I'm working on tv commercials, where in the shots folder, you may have a number of folders, depending on the job. Say if theres 200 shot folders, with the names s010, s020, s030, s040 etc, all the way up to s200. What i need to do, is be able to search for a specific shot number, and it will list the folder I've searched for. Then i need it to change dir to that said folder. – durwood Aug 12 at 23:01
  • the ss in the code is my alias to "set shot" which sets that folder as the given shot environment variable. Its used for the program i work in, Nuke. – durwood Aug 12 at 23:07

Browse other questions tagged or ask your own question.