shell rev

在linux系统上查看rev的作用

NAME
     rev — reverse lines of a file or files

SYNOPSIS
     rev [-V] [-h] [file ...]

DESCRIPTION
     The rev utility copies the specified files to standard output, reversing
     the order of characters in every line.  If no files are specified, stan‐
     dard input is read.

     -V, --version
             Output version information and exit.

     -h, --help
             Output help and exit.

上面已经说明得很清楚,其作用是反序一个文件或者多个文件的每一行。如果存在识别不是文件的情况,它就是从标准输入流中读取。先看两个文件的开头内容

test.sh的文件内容

lhj@lhj-virtual-machine:~$ cat test.sh 
#!/bin/bash
a=$(pwd)
echo ${a}

test.php的文件开头的内容

lhj@lhj-virtual-machine:~$ head test.php 
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
|--------------------------------------------------------------------------
| File and Directory Modes
|--------------------------------------------------------------------------
|
| These prefs are used when checking and setting modes when working
| with the file system.  The defaults are fine on servers with proper
| security, but you may wish (or even need) to change the values in

 使用rev反序单个文件

lhj@lhj-virtual-machine:~$ rev test.sh
hsab/nib/!#
)dwp($=a
}a{$ ohce

    使用rev反序多个文件

lhj@lhj-virtual-machine:~$ rev test.sh test.php 
hsab/nib/!#
)dwp($=a
}a{$ ohce
;)'dewolla ssecca tpircs tcerid oN'(tixe ))'HTAPESAB'(denifed ! ( fi  php?<

*/
--------------------------------------------------------------------------|
sedoM yrotceriD dna eliF |
--------------------------------------------------------------------------|
|
gnikrow nehw sedom gnittes dna gnikcehc nehw desu era sferp esehT |
reporp htiw srevres no enif era stluafed ehT  .metsys elif eht htiw |
ni seulav eht egnahc ot )deen neve ro( hsiw yam uoy tub ,ytiruces |
hcae rof ssecorp etarapes a gninnur ehcapA( stnemnorivne niatrec |
dluohs seulav latcO  .).cte ,CEXEus ehcapA htiw IGC rednu PHP ,resu |
.yltcerroc edom eht tes ot desu eb syawla |

    反序不是文件的

lhj@lhj-virtual-machine:~$ echo $a
1 2 3 4 5
lhj@lhj-virtual-machine:~$ echo ${a}|rev
5 4 3 2 1


转载于:https://my.oschina.net/u/1053706/blog/229502

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值