- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- few queries on syntax in scripting
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2013 11:46 AM
06-11-2013 11:46 AM
Hi,
I have a script, but i need your help in understanding a small portion of that script.
1) One is, what is this loop doing.. i mean n is assigned value 0, but what does (:) colon doing in while command, if we are specifying range, then it can be specified without colons (:) i think.
typeset -i n=0
while (( n < ${1:-80} )); do
(( n+=1 ))
echo "-\c"
done
4) Secondly, how we are calculating the value of "u" in below command.
typeset u=$(id)
u=${u%%\)*}; u=${u#*\(}
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2013 06:54 PM
06-11-2013 06:54 PM
Re: few queries on syntax in scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2013 11:22 PM
06-11-2013 11:22 PM
Solution>1) what is this loop doing
Are you asking what the whole fragment is doing or just what the Parameter Substitution is doing?
${1:-80}
From the ksh man page:
${parameter:-word} If parameter is set and is non-null, substitute its value; otherwise substitute word.
If the colon (:) is omitted from the above expressions, the shell only checks to determine whether or not parameter is set.
So the important character is the "-", not the colon. ;-)
>4) how we are calculating the value of "u"?
typeset u=$(id)
u=${u%%\)*}; u=${u#*\(}
$ id
uid=###(abc) gid=###(def) groups=...
This removes everything from first ")" to end. Then removes from the start to the "(".
Note this is all silly because:
$ id -un
###
So just do: typeset u=$(id -un)
>Or, again: man sh
Actually you'll be sorry. ;-)
You need: man sh-posix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2013 02:58 AM
06-12-2013 02:58 AM