User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 455,865 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,649 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 451 | Replies: 2 | Solved
Reply
Join Date: Nov 2007
Posts: 128
Reputation: k2k is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
k2k k2k is offline Offline
Junior Poster

what is not found???

  #1  
Jul 8th, 2008
I try to simply concat the arguments if they are not the same..... what is wrong with this simple code for concat???


#!/bin/sh
result=$1

shift
while [ "$#" -ne "0" ]
do

  next=$1

  if [ $result = $next ]
  then
        :
  else

     $result="$result $next"
  fi
shift
done

echo "$result"

if i run it :

$ ./foo a b c
./foo: a=a b: not found
./foo: a=a c: not found
a

why a=a b: not found??? where this came from???
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: what is not found???

  #2  
Jul 8th, 2008
> $result="$result $next"
Remove the first $ perhaps?
Like your other assignment earlier on.
Reply With Quote  
Join Date: Apr 2008
Posts: 44
Reputation: omrsafetyo is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 8
omrsafetyo omrsafetyo is offline Offline
Light Poster

Re: what is not found???

  #3  
Jul 8th, 2008
The above from Salem's post needs to be done to fix your issue.. but you may also want to fix your if statement.

if [ "$result" = "$next" ]

The data in these variables are strings and need to be compared as such.

It probably isn't necessary, but you may want to say:

if [ "${result}" = "${next}" ]
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 6:16 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC