bash version or string issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash version or string issue
# 1  
Old 12-02-2008
bash version or string issue

Hi all,

I'm not sure but I guess, that is a bash version issue.
The script working fine on "GNU bash, version 3.2.25(1)-release Ubuntu".

#!/bin/bash
while IFS=">" read a id val
do
if [[ "$id" =~ "</" ]]
then
VAL=${id%<*}; ID=${id#*</}
echo $VAL
echo $ID
sed "s|<${ID}>|${VAL}|" temp.txt >> temp
mv temp temp.txt
fi
done < file2.xml

but not running on "GNU bash (C) 2.05 SUSE".

Error message:

line 5: conditional binary operator expected
line 5: syntax error near `=~'
line 5: ` if [[ "$id" =~ "</" ]]


Any suggestions?
# 2  
Old 12-02-2008
Try this:

[[ "$id" = "</" ]]
# 3  
Old 12-02-2008
Yeah, =~ is a new operator. It matches like a regexp anywhere in
the string, use globbing instead, substitute it by:

[[ $a = *\<* ]]

HTH Chris
# 4  
Old 12-02-2008
Sorry, but none of both result working Smilie !
No records in temp.txt!
# 5  
Old 12-03-2008
If i do a little test like:

Code:
url="nothing here </really_nothing"
[[ "$url" = *\</* ]] && echo true || echo false

It results in true, so it matches. What do you get?
# 6  
Old 12-03-2008
ones again Chris, THANK YOU Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Escape bash-special character in a bash string

Hi, I am new in bash scripting. In my work, I provide support to several users and when I connect to their computers I use the same admin and password, so I am trying to create a script that will only ask me for the IP address and then connect to the computer without having me to type the user... (5 Replies)
Discussion started by: arcoa05
5 Replies

2. Shell Programming and Scripting

Backward compatibility issue with GNU bash, version 4.3.42(5)

Hi, I have made a snake game on below bash version. But it is not backward compatible. Can someone suggest a version which is most commonly used and is backward compatible so that i can change my code and share again? I have attached the game script. If someone can run it please also suggest... (5 Replies)
Discussion started by: amit14august
5 Replies

3. Linux

Linking issue due to so version number

Hi all, currently I'm facing a issue in linking a .so file. In my build machine, I've libcrypto.so.6 and there is a softlink as libcrypto.so. In my make file I'm trying to link to the lib using -L -lcrypto and it is success and created my test.exe. When I copy this test.exe to other... (4 Replies)
Discussion started by: vijkrr
4 Replies

4. UNIX for Dummies Questions & Answers

Red Hat 5.10 repository issue - desktop version

this is proving to be a real pain to set up. i recently installed red hat 5.10 desktop version. install went well. i've registered my system, but i cant seem to yum install simple packages. i can install some packages, but many others i cant. for instance, i cant do a: yum install php ... (2 Replies)
Discussion started by: SkySmart
2 Replies

5. Solaris

Solaris version issue

Hi Friends, I am new in solaris. yesterday i installed solaris in VM. now while installing weblogic setup(.bin) its giving me Invalid argument error. after some google i have two points in my mind 1) i am using solaris on intel machine. thats why i am facing this issue. If answer is yes... (3 Replies)
Discussion started by: Vishal Baghla
3 Replies

6. Shell Programming and Scripting

bash integer & string issue

Hi guys, I need for the bash code below a little bit help: cat script.sh #!/bin/bash 5_MYVALUE="test" echo "$5_MYVALUE" If I try to run the script, got follow failure: ./script.sh ./script.sh: line 4: 5_MYVALUE=test: command not found _MYVALUE My questions are how... (4 Replies)
Discussion started by: research3
4 Replies

7. Solaris

issue regarding telnet on solaris(9 version)

hi this is hrushi i have issue regarding solaris(9 version) when i telnet from solaris to linux machine it displaying message like connection closed by forine host ...when i telnet from linux to solaris its working fine ...help me its urgent and i'm new to solaris 9 (2 Replies)
Discussion started by: ghrushi84
2 Replies

8. Shell Programming and Scripting

BASH regex (convert from working perl version)

Hi there, I need to test that a variable ($VAR) matches a regex mask in BASH. I have the exact thing working in perl (below), but could somebody advise me how i would do the same in BASH ? do i need to use something like egrep ? #!/bin/perl -w my $VAR = "some value"; if ( $VAR =~... (4 Replies)
Discussion started by: rethink
4 Replies

9. AIX

Port hang issue in AIX Version 5.3

On AIX platform we are having Weblogic 8.1 as the middleware for an application. The application is deployed in Weblogic on AIX platform and the server is having 2 dedicated listening ports for any incoming requests. Output for netstat -an command for the port 30001 is as follows:- tcp4... (7 Replies)
Discussion started by: subharai
7 Replies

10. Solaris

how to upgrade bash's version ?

Dear all, How to upgrade bash's version? which way should be easy between remove the old version first and upgrade it or upgrade without remove? Please, tell me how to upgrade step by step because I'm newbie thank in advance (4 Replies)
Discussion started by: unitipon
4 Replies
Login or Register to Ask a Question