PHP让文本居中的代码,Linux_批处理实现文本内容居中显示的代码,a.txt   代码: [Promise don't come ea - phpStudy...

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

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.phpstudy.net/201010/tools/sed_phpstudy.rar

batman:思路说明:

以下代码是充分findstr命令的示例,使用findstr /n来取得行号同时兼容空行,

并将行号进行变量赋值;使用findstr /o来取得第行的字符偏移量,但要通过

上、下行的字符偏移差,因为字符偏移值是类计递加的,同时每行回车增加

两个字符偏移,所以不可避免要对最后一行强加回车,在不破坏原文件的情

况下只好生成临时文件;利用findstr /o能够一次性获得文本所有行的字符偏

移量也就是字符总数,效率和逐字符判断相比肯定是高得多了。

---------------------------------

复制代码 代码如下:

@echo off

copy /y 1.txt 2.txt>nul

echo.>>2.txt&echo end>>2.txt

for /f "tokens=1,2* delims=: " %%i in ('findstr /n /o .* 2.txt') do (

set "_%%i=%%j"&set ".%%i=%%k"

if %%i geq 2 call :lp %%i

)

del /q 2.txt&pause>nul&goto :eof

:lp

set /a n=%1-1

set /a num=_%1-_%n%-2

set /a kl=(80-num)/2

for /l %%i in (1,1,%kl%) do set /p=

call,set /p=%%.%n%%%

CSS网页布局全精通

关于JavaScript的gzip静态压缩方法

学习js所必须要知道的一些

oracle函数使用:decode和nvl函数

SQL语句判断已知表是否存在

oracle DB LINK的简单应用

JS应用DOM入门:DOM的对象属性

自动采集程序

CSS教程实例:关于网页的两列布局

Linux为什么比Windows稳定

打造安全IIS服务器之IISFAQ

常用Extjs工具:Extjs.util.Format使用方法

CSS网页调试必备:让IE7与IE8共存

纯CSS去除按钮以及链接点击时虚线

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值