- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- what's mean of ":" in shell script?
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
Forums
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
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
11-17-2004 04:33 PM
11-17-2004 04:33 PM
and in /sbin/init.d/template,
what's mean of ":"?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2004 05:04 PM
11-17-2004 05:04 PM
Re: what's mean of ":" in shell script?
It seems telling that to add code in place of ':'.
It seems to acting like a comment.
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2004 05:05 PM
11-17-2004 05:05 PM
Re: what's mean of ":" in shell script?
It does nothing other than returning an exit code of 0. Try the following script with and without :. to see the difference. It is usually used as a 'placeholder' for adding more script.
if [ -f /etc/nofile.out ]
then
echo "nofile is there"
else
:
fi
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2004 05:11 PM
11-17-2004 05:11 PM
Re: what's mean of ":" in shell script?
or you can think of this like a place-holder in you code.
if [ ! -f myfile ]
:
# this is a comment
else
echo "the file myfile is valid"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2004 01:23 AM
11-18-2004 01:23 AM
Re: what's mean of ":" in shell script?
Example, in MC/SG, sometimes, I only want to mount the file systems in a package - but not start up SAP:
{
# ADD customer defined run commands.
: # do nothing instruction, because a function must contain some command.
# /etc/cmcluster/PRODDBCI/sapdbci.cntl startDBCI PROD
test_return 51
}
If I didn't have the : then the script would fail...
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2004 02:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2004 08:23 AM
11-18-2004 08:23 AM
Re: what's mean of ":" in shell script?
while :
do
:
done
This script loops around as fast as possible, doing nothing useful and consuming 100% of one CPU.
Now in the template file, the line says:
# Execute the commands to start your subsystem (replace :)
:
set_return
So you take out the : and put your command(s) on that line. Without the :, there would be: else fi, and you'll get the famous: "`fi' is not expected." error message.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2004 10:22 AM
11-18-2004 10:22 AM
Re: what's mean of ":" in shell script?
a variable isn't already set.
: ${somevar:="default"}
print ${somevar}
default
without the ':' you get
${somevar:="default"}
/usr/bin/sh: default: Execute permission denied.