|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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=")"
__________________
"I feel so miserable without you; it's almost like having you here" - Stephen Bishop |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Problem with string manipulation in bash |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|