bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to supply a string with space in it as parameter to a function?


From: Peng Yu
Subject: How to supply a string with space in it as parameter to a function?
Date: Wed, 23 Jun 2010 17:37:10 -0500

Hi,

According to man bash, I thought that $@ instead of $* can help me
pass a string with space as a parameter. But it is not. Would you
please show me how to print 'b c' as a single argument in the
following code?

#!/usr/bin/env bash

function f {
#for i in $*;
for i in $@;
do
  echo $i
done
}

f a 'b c' d e f g


$ ./main.sh
a
b
c
d
e
f
g

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]