如何使字符行跨命令行宽度? [英] How to make a character line across the width of the command line?
本文介绍了如何使字符行跨命令行宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Windows命令行的整个宽度上制作字符行?
How to make a character line across the width of the command line Windows?
在Linux中,我可以这样做
In Linux, I can do like this
printf '\n%*s\n\n' \"${COLUMNS:-$(tput cols)}\" '' | tr ' ' -
在Windows中,到目前为止,我只有
In Windows, I have so far only
echo -----------------------
推荐答案
您可以使用模式$ c获得窗口的当前宽度。 $ c>命令。
@echo off
setlocal enabledelayedexpansion
"set width="
for /f "tokens=2 delims=:" %%a in ('mode con^|more +4') do if not defined width set /a width=%%a
for /l %%a in (1,1,%width%) do set "line=!line!-"
echo %line%
这篇关于如何使字符行跨命令行宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文