The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
line 85: unexpected EOF while looking for matching `"' Freakhan Shell Programming and Scripting 6 06-07-2009 02:01 PM
Unexpected characters King Nothing Shell Programming and Scripting 4 04-30-2009 10:03 AM
counting the lines matching a pattern, in between two pattern, and generate a tab d.chauliac Shell Programming and Scripting 4 03-19-2009 01:30 PM
Unexpected EOF while looking for matching `"' BlueberryPickle Shell Programming and Scripting 2 01-20-2009 07:58 PM
comment/delete a particular pattern starting from second line of the matching pattern imas Shell Programming and Scripting 4 10-13-2008 03:37 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-22-2009
questionasker questionasker is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 8
pattern matching w/ unexpected characters

how do i check if the first character is a parenthese in pattern matching?

if [[ $a == (* ]] obviously doesnt work. How do I use it to compare so it doesnt try to use it to group.
  #2 (permalink)  
Old 06-22-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
one way to skin that cat:

Code:
#!/bin/ksh
set -x

a='(abc'

if [[ "${a%%${a##?}}" = '(' ]]; then
   echo '( - first char'
fi

  #3 (permalink)  
Old 06-22-2009
questionasker questionasker is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 8
what about if the string assigned to the variable isn't a constant length? i.e. the string assigned to that variable changes.
  #4 (permalink)  
Old 06-22-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
Quote:
Originally Posted by questionasker View Post
what about if the string assigned to the variable isn't a constant length? i.e. the string assigned to that variable changes.
it'd not bite if you try.
  #5 (permalink)  
Old 06-22-2009
questionasker questionasker is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 8
Quote:
Originally Posted by vgersh99 View Post
it'd not bite if you try.

i'd love to, im just at home Something for tomorrow i suppose.
  #6 (permalink)  
Old 06-22-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,554

Code:
# a="(dsfsf"
# case $a in \(* ) echo ok;; esac
ok

awk

Code:
echo $a | awk '{print /^\(/?"ok":"not ok"}'

Reply

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0