[ubuntu-uk] Bash and Path checks

Tony Travis a.travis at abdn.ac.uk
Mon Apr 20 13:27:30 BST 2009


Cornelius Mostert wrote:
> Thanx but I am familiar with / in Linux and \ in windows... i saw a
> script use \ as i did and naturally I assumes (incorrectly though)
> that it is also | (pipe) but backward pipe like <, come to think of it
> the path the person wanted to append to the variable a path that
> contained a space in it so that is why he used the \ to make the
> script use the space in the path and not think that it is a second
> parameter...
> 
> UMmmm Note to self and others try not to use spaces in file paths :-)
> but then again you guys know that ...

Hello, Cornelius.

You do sometimes see '\' after a pipe, when it is used to escape 
newlines, in order to make shell scripts more readable. For example the 
one-line pipeline:

command1 with lots of arguments | command2 with many more arguments

Can be written on two lines as:

command1 with lots of arguments |\
command2 with many more arguments

This pipeline can also be written as:

command1 with lots of arguments \
| command2 with many more arguments

I prefer the second style, which makes it more obvious what the scope of 
the pipeline is. You can put quotes around "paths with spaces in them".

Bye,

	Tony.
-- 
Dr. A.J.Travis, University of Aberdeen, Rowett Institute of Nutrition
and Health, Greenburn Road, Bucksburn, Aberdeen AB21 9SB, Scotland, UK
tel +44(0)1224 712751, fax +44(0)1224 716687, http://www.rowett.ac.uk
mailto:a.travis at abdn.ac.uk, http://bioinformatics.rri.sari.ac.uk/~ajt



More information about the ubuntu-uk mailing list