Skip to content

Latest commit

 

History

History
21 lines (15 loc) · 492 Bytes

2015-06-27-bash-too-many-arguments.md

File metadata and controls

21 lines (15 loc) · 492 Bytes
tags
bash error

{% highlight bash %} if test ! -f $path {% endhighlight %}

The above script would create bash warnings for you like

{% highlight bash %} test: too many arguments {% endhighlight %}

The problem here is that the path contains spaces in it, and thus the test gets “more than one arguments”.

The solution for the above problem is a pretty simple one, wrap the path in inverted commas 😅.

{% highlight bash %} if test ! -f “$path” {% endhighlight %}