Check if string starts with $ symbol


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Check if string starts with $ symbol
# 1  
Old 10-28-2011
Check if string starts with $ symbol

How do I check that a string $AA22CC3 starts with the "$" symbol ?

I have tried :

Code:
checksum='$AAB3E45'
echo $checksum


case $checksum in 
$* ) echo success ;
esac

Thanks ...
# 2  
Old 10-28-2011
try \$
tip78
# 3  
Old 10-28-2011
Do you know how to escape characters that have special meaning to the shell...
# 4  
Old 10-28-2011
Escape the dollar sign.

Code:
\$* ) echo success ;

This User Gave Thanks to MacMonster For This Post:
# 5  
Old 10-28-2011
Thanks MacMonster, escape did the trick
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check if a string starts with certain values and ends with numbers

This is very basic. Yet Iam struggling to get the right pattern for my check. Apologize in advance to ask a very lame question. I have to validate if a value of the variable starts with "efgh" and followed by 6 numbers. Var1="efgh234567" The condition Iam trying to achieve is similar to... (6 Replies)
Discussion started by: deepakwins
6 Replies

2. Shell Programming and Scripting

Need to write a shell script that starts one, then kills it, then starts another?

This is on a CentOS box, I have two scripts that need to run in order. I want to write a shell script that calls the first script, lets it run and then terminates it after a certain number of hours (that I specify of course), and then calls the second script (they can't run simultaneously) which... (3 Replies)
Discussion started by: btramer
3 Replies

3. Shell Programming and Scripting

Check file for string existence before appending it with string

I want to append file with a string but before doing that i want to check if this string already exist in that file.I tried with grep on Solaris 10 but unsuccessful.Man pages from grep seems to suggest if the string is found command status will be 0 and if not 1.But i am not finding it.May be i... (2 Replies)
Discussion started by: sahil_shine
2 Replies

4. Shell Programming and Scripting

How to check if a filename in a directory starts with a certain string

Hello, Trying to iterate over set of file in current directory and check if the file name in that folder matches certain string. This is what I have so far. Here I am checking if the file name starts with nexus, if so echo file name to log file. Getting weird syntax errors. Any help is... (7 Replies)
Discussion started by: scorpioraghu
7 Replies

5. UNIX for Dummies Questions & Answers

grep line for string up to symbol

Hi, I would like to extract a pattern from a line. The first two characters will always be the same in this pattern, but the proceeding numbers will not be, and the pattern will always be 6 characters long. I would like to get the entire pattern up to a certain symbol, in this case, a period. ... (3 Replies)
Discussion started by: goodbenito
3 Replies

6. Shell Programming and Scripting

Stripping of a symbol from string not working properly

Hi All, I used this code to strip-off $-symbol from string values. a="$980" b="897" a=`echo "$a" | sed 's/$/ /g'` b=`echo "$b" | sed 's/$/ /g'` echo "$a" echo "$b" but this results in the output: 80 and 897 it works when i use a='$987' b='890' (13 Replies)
Discussion started by: angie1234
13 Replies

7. Solaris

/usr/lib/passwdutil.so.1: symbol __nsl_fgetspent_r: referenced symbol not found

deleteing post (0 Replies)
Discussion started by: dshakey
0 Replies

8. Shell Programming and Scripting

Get string from file after nth symbol

I've got a file, where I want to grab two fields from it. The file isn't fixed format, so all I know is that the two fields are after a certain number of delimiters within the record. File e.g. as follows:- "1"^"HEADER"^ "5"^"12345678"^"Smith"^"Dave"^"Mr"^"Research &... (1 Reply)
Discussion started by: daveaasmith
1 Replies

9. Shell Programming and Scripting

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies
Login or Register to Ask a Question