• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >DOS/BAT > 批处理实现文本内容居中显示的代码

批处理实现文本内容居中显示的代码

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了批处理替换文本内容,批处理修改文本内容,批处理删除文本内容,vb清除文本框内容代码,文本内容等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
a.txt  
代码:

[Promise don't come easy]
I should have known all along.
There was something wrong.
I just never read between the lines.
Then I woke up one day and found you on your way.
Leaving nothing but my heart behind.
What can I do to make it up to you.
Promises don't come easy.
But tell me if there's a way to bring you back home to stay.
Well I'd promises anything to you.
I've been walkin' around with my head hanging down.
Wondrin' what I'm gonna do.
'Cause when you walked out that door.
要求,CMD原始窗口中,不调节窗口大小,不生成临时文件,居中显示文本内容。输出如下:
代码:


[Promise don't come easy]
I should have known all along.
There was something wrong.
I just never read between the lines.
Then I woke up one day and found you on your way.
Leaving nothing but my heart behind.
What can I do to make it up to you.
Promises don't come easy.
But tell me if there's a way to bring you back home to stay.
Well I'd promises anything to you.
I've been walkin' around with my head hanging down.
Wondrin' what I'm gonna do.
'Cause when you walked out that door.

Batcher:

sed -e :a -e "s/^.\{1,77\}$/ & /;ta" a.txt

sed.exe
http://xiazai.jb51.net/201010/tools/sed_jb51.rar 

batman:思路说明:
以下代码是充分findstr命令的示例,使用findstr /n来取得行号同时兼容空行,
并将行号进行变量赋值;使用findstr /o来取得第行的字符偏移量,但要通过
上、下行的字符偏移差,因为字符偏移值是类计递加的,同时每行回车增加
两个字符偏移,所以不可避免要对最后一行强加回车,在不破坏原文件的情
况下只好生成临时文件;利用findstr /o能够一次性获得文本所有行的字符偏
移量也就是字符总数,效率和逐字符判断相比肯定是高得多了。
---------------------------------
</div> </div>

您可能想查找下面的文章:

  • 批处理实现文本内容居中显示的代码
  • 批处理中实现替换文本内容

相关文章

  • dos下遍历目录和文件的代码(主要利用for命令)
  • 再谈DOS批处理下格式化日期字符串的多种方法(详解)
  • 开始→运行(cmd)命令大全第1/2页
  • 用批处理实现读取文本文件并实现超链接代码的输出 原创
  • 使用批处理禁用(启用)组策略的代码
  • 使用bat批处理来安装和卸载ASP组件
  • bat批处理实现的创建10个文件夹,文件夹再包含5个空文件夹
  • cmd if条件 条件判断
  • 系统配置—获得更多常规内存
  • cmd批处理转义字符%的详细解释

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • 批处理设置文件访问权限的方法分享
    • 用批处理生成网页文件并打开的代码
    • 使用批处理bat更改hosts的多个方法
    • Append、Debug、Diskcomp命令的使用说明
    • 批处理备份文件夹和文件后发布文件夹至网站
    • 用bat操作注册表实现不显示扩展名
    • 以后经常需要知道CMD/DOS下符号的作用参考,正好发现了这篇
    • 批处理 正则表达式(findstr) 整理
    • 用批处理实现禁止运行指定程序
    • 批处理FTP上传文件

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有