I am a pythoneer, guess List is called hash in shell script , I want to know how to do this

for arg in "$@";
do
echo `pwd`'/'$arg;
done

how do i pass the collected this list of items in $args to a different applications that takes these items as list.

for arg in "$@"
do
  echo `pwd /${arg}`
done

Although I do not know why you are including a leading slant there, or, actually, ANY argument to pwd. Or are you intending to pass an OPTION to pwd, in which case it should "-" and not "/". "/" is the windows form for options.

hi krystosan,

what if you start from the beginning?

what list are talking about?
does the <command> take a list of arguments, or does it take only one argument, and so have to be executed many times?
and so on.

The idiomatic way to do this through pipes. As an example, consider the two following scripts:

a.sh

for arg in $@; do
   echo `pwd`/${arg}
done

b.sh

while read line; do
   echo "New entry: ${line}"
done

If the output of a.sh was:

/tmp/foo/1
/tmp/foo/2
/tmp/foo/3

and you piped that to b.sh (i.e. a.sh | b.sh) you would get

New entry: /tmp/foo/1
New entry: /tmp/foo/2
New entry: /tmp/foo/3

This delivers your output as a set of lines to the second program but acts (to the while loop iteration) as a set of inputs as if it were an array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.