variables - Bash avoid filename interpretation -


i'm looking @ aliases save current directory can opened later.

alias cdo='pwd|sed 's/ /\ /g' > ~/.cdo' aiias cdn='cd "$(cat ~/.cdo)"' 

the sed command deals spaces.

however, still have curious problem cannot fix must involve variable interpretation.

jk@bt:~# cd hello\ world/ jk@bt:~/hello world# pwd|sed 's/ /\\ /g' > ~/.cdo jk@bt:~/hello world# cat ~/.cdo /home/jk/hello\ world jk@bt:~/hello world# cd .. jk@bt:~# cd "$(cat ~/.cdo)" bash: cd: /home/jk/hello\ world: no such file or directory 

looks me if you're doubling masking.

one way handle spaces mask them individually backslash:

 cd here\ i\ go  

or mask of them double quotes:

 cd "here go"  

while allowed well:

 cd here" "go 

however, mixing them means, want literally backslashes:

 cd "here\ i\ go"  

and that's what's happening.

note while not common, tabs , newlines can included in files well. masking them works same way, reading them file might different, , multiple blanks condensed shell single one.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -