You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.2 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# **seq**
## 说明
**seq命令** 用于产生从某个数到另外一个数之间的所有整数
## 选项
```markdown
用法seq [选项]... 尾数
 seq [选项]... 首数 尾数
 seq [选项]... 首数 增量 尾数
-f, --format=格式 使用printf 样式的浮点格式
-s, --separator=字符串 使用指定字符串分隔数字(默认使用:\n
-w, --equal-width 在列前添加0 使得宽度相同
```
## 实例
```bash
seq -f"%3g" 9 11 # -f选项指定格式,`%`后面指定数字的位数 默认是`%g``%3g`那么数字位数不足部分是空格
seq 10 | tr '\n' +; echo 0 | bc # 输出1+2+3+4+5+6+7+8+9+10+0
# 下面这样的话数字位数不足部分是0`%`前面制定字符串
sed -f"%03g" 9 11
seq -f"str%03g" 9 11
seq -w 98 101 # -w选项指定输出数字同宽不能和`-f`一起用,输出是同宽的
seq -s" " -f"str%03g" 9 11 # -s选项指定分隔符(默认是回车)
seq -s"`echo -e "/t"`" 9 11 # 要指定`/t`做为分隔符号:
seq -s"`echo -e "\n"`" 9 11 # 指定`\n`作为分隔符号会得到错误结果,因为它默认的就是回车作为分隔符
```