UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old May 5th, 2008, 07:43 PM
u_hafeez u_hafeez is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 55 u_hafeez Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 6 h 59 m 50 sec
Reputation Power: 0
Problem with string manipulation in bash

i have this code


Code:
#bin/bash
$SUB=":"
$REP=")"

if [ $# -eq 0 ]
then echo "please pass a filename as a an argument"
else
{
if [ -f $1 ]
then
{
$VAR | grep -n $USER $1; echo  -n $VAR
$newVAR=${$VAR/$SUB/$REP}
}
fi
}
fi


i get error scriptname:line 2: = :: command not found
and scriptname:line 3: =): command not found

how do fix this.

also how do i put the regular expression line so that it replaces all the colons in bigenning of all lines in $VAR instead of just the first one? (i am not allowed to use sed or awk for this exercise or a temp file)

Last edited by u_hafeez : May 5th, 2008 at 07:49 PM.

Reply With Quote
  #2  
Old May 6th, 2008, 04:12 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 671 SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 23 h 26 m 49 sec
Reputation Power: 196
Don't user $ at start of a variable assignmnemt, unless you intend to have the contents of the variable be the variable name being assigned to:

Code:
SUB=":"
REP=")"
etc.
__________________
"I feel so miserable without you; it's almost like having you here" - Stephen Bishop

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Problem with string manipulation in bash


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway