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 425,898 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 1,932 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: 386 | Replies: 2 | Solved
Reply
Join Date: Nov 2007
Posts: 122
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,638
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 
Rep Power: 22
Solved Threads: 415
Colleague
Salem's Avatar
Salem Salem is offline Offline
void main'ers are DOOMed

Re: what is not found???

  #2  
Jul 8th, 2008
> $result="$result $next"
Remove the first $ perhaps?
Like your other assignment earlier on.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Reply With Quote  
Join Date: Apr 2008
Posts: 39
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 7:35 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC