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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Korn: How to loop through a string character by character shew01 Shell Programming and Scripting 10 17 Hours Ago 04:58 AM
read a variable character by character, substitute characters with something else vipervenom25 UNIX for Dummies Questions & Answers 2 06-06-2008 12:18 PM
replace a character with another character satish@123 Shell Programming and Scripting 4 05-19-2008 02:57 AM
Can i read a file character by character karnan Shell Programming and Scripting 6 05-18-2008 11:22 PM
Can I read a file character by character? murtaza Shell Programming and Scripting 3 03-29-2007 08:19 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-30-2006
Registered User
 

Join Date: Jan 2006
Posts: 7
how to get one character

I just need to know how to get one character in a string

i tried
Code:
if [[ $# -eq 1 ]] && [[ cut -b54 $1 -ne 'X' ]]
but that didnt seam to work keep coming up that -b5 was unexpected.

i am not sure if the cut command is a good way of doing this.

i am still trying to figure it out. any help would be good

cheers
Reply With Quote
Forum Sponsor
  #2  
Old 01-30-2006
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Almost there.... you need backticks
Code:
if [[ $# -eq 1 ]] && [[ `cut -b54 $1` -ne 'X' ]]
Cheers
ZB
Reply With Quote
  #3  
Old 01-30-2006
Registered User
 

Join Date: Jan 2006
Posts: 7
cheers zazzybob, now it just seams to come up with the error

Code:
iip[44]: cut -b54 $1: bad number
i have tried varing the number but that doesnt seam to be a problem if i use it on command line it works no problem. is it because its in an if statement (which i doubt)

eh i not sure

ksh for anyone that needs to know
Reply With Quote
  #4  
Old 01-30-2006
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Ahh... ksh - you'll need

`cut...` != 'X'

Cheers
ZB
Reply With Quote
  #5  
Old 01-30-2006
Registered User
 

Join Date: Jan 2006
Posts: 7
cool that works, but my program doesnt

the $1 was a file name and all i wanted to know was if it existed or not. but that doest want to work either. but i did learn something and that otherwise works great, and it has put my closer to fix my problem

cheers
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0