Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 2nd, 2004, 02:34 PM
linh linh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 245 linh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 27 sec
Reputation Power: 10
Interpreting Bash command firstchar=${1:0:1}

Interpreting Bash command firstchar=${1:0:1}

1) What does the code on line 8) firstchar=${1:0:1} do ?
2) $ stand for an argument, but what does {1:0:1} do ?

=========================
Code:
1) if [[ $# -eq 2 ]]
2) then
3)   if [[ "$1" != "$2" ]]
4)   then
5)    exit 1 
6)   fi
7) else
8)  firstchar=${1:0:1}
9)  if [[ "$firstchar">"/" && "$firstchar"<":" ]]
10)  then
11)   exit 2   # username cannot start with a number
12)  fi
13) fi

Reply With Quote
  #2  
Old June 17th, 2010, 10:24 AM
PMDubuc PMDubuc is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2010
Posts: 1 PMDubuc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 57 sec
Reputation Power: 0
Answers:

1) It puts the first character of $1 in $firstchar.
2) ${1:0:1} expands to a substring of $1 starting at character 0 and getting 1 character. So the 0 is the starting index of the substring and the 2nd 1 is the number of characters in the substring.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Interpreting Bash command firstchar=${1:0:1}

Developer Shed Advertisers and Affiliates



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap