The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help to escape special characters in Korn shell script rogers42 UNIX for Dummies Questions & Answers 6 05-14-2009 08:23 AM
Bourne Shell: Special characters Input Prevention totziens Shell Programming and Scripting 37 04-23-2008 05:05 AM
unescaping special characters sriram_r Shell Programming and Scripting 3 02-06-2008 07:59 AM
special characters nawnaw UNIX for Dummies Questions & Answers 2 05-18-2004 04:17 PM
awk/sed with special characters apalex Shell Programming and Scripting 5 05-06-2002 05:40 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-23-2005
Doug97 Doug97 is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 1
Can't stop shell interpreting special characters

I am struggling with the following sample code:


Code:
array1=(a b c d)
array2=(* * * *)

print ${array1[2]}
print ${array2[2]}

It returns 'c' and the name of a file in the directory I'm in.

I can't for the life of me work out how to prevent the shell interpreting the '*' and just get it to return the plain character ... is there a way to do this?


Also, my Learning the Korn Shell book lists several sed-like functions you can use to edit variable names, e.g.


Code:
variable=string
variable=${variable/g/gs}
print $variable

returns 'strings'. But Sed has a function where you can 'store' part of the pattern matched, and get it back in the replacement string, e.g.


Code:
print $variable | sed "s/\(strin\)g/\1/"

returns 'strin'. Does the Korn shell have a similar feature that's not in my book?
 

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 09:13 AM.


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