bash: passing paths with spaces as parameters?

前端 未结 4 897
北海茫月
北海茫月 2021-02-12 22:14

I have a bash script that recieves a set of files from the user. These files are sometimes under directories with spaces in their names. Unfortunately unlike this question all t

4条回答
  •  爱一瞬间的悲伤
    2021-02-12 22:56

    Bravo @Roland . Thans a lot for your solution

    It has really worked!

    I wrote a simple script function that opens a given path with nautilus.

    And I've just nested a function with this "helper"-for-loop into the main function:

    fmp ()  {
    
        fmp2() { 
            nautilus "$@"; 
        };
    
        for fname in "$@";
        do         
            fmp2 "$fname";         
        done; 
    }
    

    Now I'm able to make all my scripts work handling with paths just by turning them into nested functions wrapped by a function with this helper-for-loop.

提交回复
热议问题