【Linux】一步一步学Linux——seq命令(221)
生活随笔
收集整理的這篇文章主要介紹了
【Linux】一步一步学Linux——seq命令(221)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
00. 目錄
文章目錄
- 00. 目錄
- 01. 命令概述
- 02. 命令格式
- 03. 常用選項
- 04. 參考示例
- 05. 附錄
01. 命令概述
seq命令用于產(chǎn)生整數(shù)序列。
02. 命令格式
用法:seq [選項]... 尾數(shù)seq [選項]... 首數(shù) 尾數(shù)seq [選項]... 首數(shù) 增量 尾數(shù)03. 常用選項
以指定增量從首數(shù)開始打印數(shù)字到尾數(shù)。-f, --format=格式 使用printf 樣式的浮點格式-s, --separator=字符串 使用指定字符串分隔數(shù)字(默認使用:\n)-w, --equal-width 在列前添加0 使得寬度相同--help 顯示此幫助信息并退出--version 顯示版本信息并退出04. 參考示例
4.1 輸出1-5
[deng@localhost ~]$ seq 5 1 2 3 4 5 [deng@localhost ~]$4.2 輸出1-5
[deng@localhost ~]$ seq 1 5 1 2 3 4 5 [deng@localhost ~]$4.3 輸出3-5
[deng@localhost ~]$ seq 3 5 3 4 5 [deng@localhost ~]$4.4 輸出1 4 7 10
[deng@localhost ~]$ seq 1 3 10 1 4 7 10 [deng@localhost ~]$4.5 指定格式輸出
[deng@localhost ~]$ seq -f "%3g" 9 1191011 [deng@localhost ~]$意思是-f指定格式,%后面指定3位數(shù),默認是%g,%3g不夠位數(shù)的地方都是空格填補
4.6 指定格式輸出
[deng@localhost ~]$ seq -f "%03g" 9 11 009 010 011 [deng@localhost ~]$意思是打印三位,不足的地方用0填補
4.7 指定格式輸出
[deng@localhost ~]$ seq -f "str%03g" 9 11 str009 str010 str011 [deng@localhost ~]$意思是打印三位不足的地方以0填補,在前面加上str
4.8 在列前添加0使得寬度相同
[deng@localhost ~]$ seq -w 9 11 09 10 11 [deng@localhost ~]$當輸出等寬字符串時不應(yīng)再指定格式字符串,-w與-f不能一起用
4.9 使用指定字符串分隔數(shù)字
[deng@localhost ~]$ seq -s " " -f "str%03g" 9 11 str009 str010 str011 [deng@localhost ~]$4.10 使用tab鍵分隔數(shù)字
[deng@localhost ~]$ seq -s "`echo -e '\t'`" 9 11 9 10 11 [deng@localhost ~]$先用命令做成一個tab,然后再指定成分隔符
05. 附錄
參考:【Linux】一步一步學Linux系列教程匯總
總結(jié)
以上是生活随笔為你收集整理的【Linux】一步一步学Linux——seq命令(221)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Linux】一步一步学Linux——r
- 下一篇: 【Linux】一步一步学Linux——s