bash 整数对比_如何在bash中以0填充整数?

bash 整数对比

How to convert an integer into a string of many characters padded with 0s in bash.

如何转换为整数到字符串中的字符与在bash 0填充。

To do this in C:

要在C中执行此操作:

sprintf(buffer, "%08d", n);

which convert integer n to a 8-character string padded with leading 0s.

它将整数n转换为由前导0填充的8个字符的字符串。

How to padding a integer with 0s in bash?

如何在bash中以0填充整数?

In bash, you can also use printf

在bash中,您也可以使用printf

For the previous example:

对于前面的示例:

str=$(printf "%08d" $n)

where $n is the integer and $str contains the converted string.

其中$ n是整数,$ str包含转换后的字符串。

Answered by anonymous.
匿名回答。

翻译自: https://www.systutorials.com/how-to-padding-a-integer-with-0s-in-bash/

bash 整数对比

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值