Globbing/pathname expansion with colon as separator

前端 未结 8 1297
鱼传尺愫
鱼传尺愫 2020-12-28 16:23

How can I convert a string containing glob characters such as

/var/lib/gems/*/bin

into a colon-separated string of filenames (i.e. PATH com

相关标签:
8条回答
  • 2020-12-28 16:50
    printf "%s\n" /var/lib/gems/*/bin | tr "\n" ":"
    
    0 讨论(0)
  • 2020-12-28 16:52

    It's pretty trivial if you drop into Perl:

    perl -e 'print join ":", @ARGV' /var/lib/gems/*/bin
    

    Or Python:

    python -c 'import sys; print ":".join(sys.argv[1:])' /var/lib/gems/*/bin
    

    Or any number of other popular scripting languages.

    0 讨论(0)
提交回复
热议问题