Linux Gvim Shell printf Command

Source: Internet
Author: User

#printf命令, format the output statement
#用于格式化输出, is the echo-enhanced version, a limited variant of the C-Language printf library function, with slightly different syntax
#是由POSIX标准所定义, the transplant is better than echo.
#printf不会像echo自动换行, so add \ n to break the line, as follows:

1 " This is a test \ n " 2 " OK? \ n "

#语法: printf format-string# Format Control string # [arguments# parameter list #]
#与C语言printf函数不同如下
# 1.printf command without parentheses
# 2.format-string can be without quotes, but preferably plus, single double quotes can be
# 3. Parameter extra format control (%), format-string can be reused, all parameters can be replaced
# 4.arguments using spaces to separate
#示例如下:
# format-string is double quotes, output 1 ABC

1 " %d%s \ n " 1 " ABC "

# single quotes and double quotes effect, output 1 abc\

1 ' %d%s \ n ' 1 " ABC "

# The format specifies only one parameter, but the extra parameter is still output in that format, format-string is reused

1 ' %s\n ' AAA BBB 2 ' %s%s%s \ n ' a b c d E F g

# If there is no arguments, then%s is replaced with null, and%d is replaced with 0. Output results: 0

1 ' %s and%d \ n '

The string is displayed in the format #如果以%d, and an invalid number is indicated, at which time the default value is 0. Output Result: Hello 0

1 " The first program always prints%s%d\n " Hello Shell

Linux Gvim Shell printf Command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.