Linux shell basic2 cat find tr
Cat stands for concatenate.
Case 1.
When the text files have more blank lines, we want to remove them.
We can use regex \s+ '\n'.
cat file.txt | tr \s '\n'
cat -T file.txt # show tabs as ^.
cat -n file.txt # show line numbers
. Specifies current directory and .. Specifies the parent directory. This convention is followed throughout the Unix file system.
find . -iname "*.txt"
i means ignore the case.
find . \( -name "*.txt" -o -name "*.pdf" \) -print
./text.pdf
./new.txt
find . -iregex ".*\(\.py\|\.sh\)$"
./test.py
./new.PY
find . ! -name "*.txt" -print
Files not end with .txt.
find . -maxdepth 1 -type f -print
Just show file and not traverse the sub folder.
find . -type d
Just show the directory
Type :
f : file
d: directory
l: link
Print all the files that were accessed within the last 7 days as follows:
$ find . -type f -atime -7 -print
atime: access time
mtime: modify time
-ctime:change time
n order to print all the files that are having access time older than seven minutes, use the
following command:
$ find . -type f -amin +7 -print
For example, find all the files that are having a modification time greater than that of the
modification time of a given file.txtfile as follows:
$ find . -type f -newer file.txt -print
Search based on file size
Based on the file sizes of the files, a search can be performed as follows:
$ find . -type f -size +2k
# Files having size greater than 2 kilobytes
Instead of kwe can use different size units as the following:
b– 512 byte blocks
c– bytes
w– two byte words
k– Kilobyte
M– Megabyte
G– Gigabyte
find . -type f -name "*.c" -exec cat {} \;>all_c_files.txt
$ cat example.txt # Example file
1 2 3 4 5 6
7 8 9 10
11 12
$ cat example.txt | xargs
1 2 3 4 5 6 7 8 9 10 11 12
$ cat example.txt | xargs -n 3
1 2 3
4 5 6
7 8 9
10 11 12
echo "hello linux" | tr 'a-z' 'A-Z'
HELLO LINUX
echo "Hello 123 world 456" | tr -d '0-9'
Hello world
echo hello 1 char 2 next 4 | tr -d -c '0-9 \n'
1 2 4
echo "I am your friends?" | tr -s ' '
I am your friends?
find -type f | xargs md5sum
e8bc686b2c380b9ad56c024a03384150 ./sub/java.txt
a5bf231497e5d503172bfd39a387b197 ./all_txt_files.txt
e827b6437257f24b9e5fbba44fd98f5c ./num.txt
b6d9275e7e16b154059677fac91baa79 ./test.txt
b6d9275e7e16b154059677fac91baa79 ./mul_bank.txt
sort -r : sort in reverse order
Split can used to split file to specify size.
Linux shell basic2 cat find tr的更多相关文章
- Linux Shell脚本编程while语句案例
1,每隔3秒,打印一次系统负载 #!/bin/bash while true do uptime done 2,把监控结果保存到文件,在后台执行,然后用tail -f监控文件变化 ghostwu@de ...
- linux shell脚本之-变量极速入门与进阶(2)
1,$$:显示当前的进程id号 ghostwu@dev:~/linux/shell/how_to_use_var$ cat show_pid.sh #!/bin/bash echo $$ ghostw ...
- linux shell脚本之-变量极速入门与进阶(1)
1,如果创建shell脚本? 使用任意文本编辑软件,一般为vim,创建.sh结尾的文件,在文件的最开头用 #!/bin/bash 注明shell的类型 如: ghostwu@dev:~/linux/s ...
- Linux Shell脚本编程while语句
Linux Shell脚本编程while语句案例 1,每隔3秒,打印一次系统负载 #!/bin/bash while truedo uptime sleep 3done 2,把监控结果保存 ...
- Linux Shell 文本处理工具集锦--Awk―sed―cut(row-based, column-based),find、grep、xargs、sort、uniq、tr、cut、paste、wc
本文将介绍Linux下使用Shell处理文本时最常用的工具:find.grep.xargs.sort.uniq.tr.cut.paste.wc.sed.awk:提供的例子和参数都是最常用和最为实用的: ...
- Linux shell tr 命令详解
该随笔摘自 https://www.jb51.net/article/103892.htm Linux shell tr 命令详解 1. 用途 tr,translate的简写,主要用于压缩重复字符,删 ...
- linux shell的here document用法(cat << EOF)
什么是Here Document?Here Document 是在Linux Shell 中的一种特殊的重定向方式,它的基本的形式如下cmd << delimiter Here Docu ...
- (转)linux shell 的here document 用法 (cat << EOF)
什么是Here Documen: Here Document 是在Linux Shell 中的一种特殊的重定向方式,它的基本的形式如下 cmd << delimiter Here Docu ...
- Linux SHELL 命令入门题目答案(一)
1.如何使用shell 打印 “Hello World!” (1)如果你希望打印 !,那就不要将其放入双引号中,或者你可以通过转义字符转义(2)echo 'hello world!' 使用单引号ech ...
随机推荐
- 随笔分类 - 无废话ExtJs系列教程
随笔分类 - 无废话ExtJs系列教程 摘自:http://www.cnblogs.com/iamlilinfeng/category/385121.html ExtJs 入门教程 摘要: extjs ...
- csharp: MVC Controls
http://mvccontrolstoolkit.codeplex.com/ MVC Controls Toolkit http://mvcjquerycontrols.codeplex.com/ ...
- ningx配置ModSecurity重启出现兼容性问题:ModSecurity: Loaded PCRE do not match with compiled!的解决方法
nginx开启错误日志,然后重启nginx,出现如下信息: 2016/12/03 09:40:38 [notice] 18858#0: ModSecurity for nginx (STABLE)/2 ...
- 推荐两个很好用的javascript模板引擎
http://www.jsviews.com/#jsrender,支持if/for等常用逻辑,自称下一代jquery template plugin标准 https://github.com/janl ...
- ES6中generator传参与返回值
先看两个例子, 1, function* f() { for(var i=0; true; i++) { var reset = yield i; if(reset) { i = -1; } } } ...
- gulp入坑系列(4)——gulp的代码转换
当然,gulp不仅仅能转换Sass,这里会提到如下转换: jsx转换成常规的JavaScript(说到jsx,玩过react的同学应该是知道的) es6转换为es5 Less,Sass转换为CSS 首 ...
- ASP.Net页面刷新后自动滚动到原来位置
在网上搜索之后总结了三种方式: 1.设置Page中的MaintainScrollPositionOnPostback属性为true A>.页面里有MaintainScrollPositionOn ...
- SharePoint 2010 文档管理系列之星级评论功能
前言:正如我们前面介绍的是,文档管理就是让大家更加直观.方便的对手里的文档,进行统筹掌控,哪些文档是有价值的,哪些文档更受大家欢迎,所有就带来了这个星级评论. 当然,这个是SharePoint 201 ...
- 深入底层逆向分析TDC‘s keygenme(手脱压缩壳)
系统 : Windows xp 程序 : TDC‘s keygenme 程序下载地址 :http://pan.baidu.com/s/1gdWyt6z 要求 : 脱壳 & 注册机编写 使用工具 ...
- java多线程系列6-阻塞队列
这篇文章将使用经典的生产者消费者的例子来进一步巩固java多线程通信,介绍使用阻塞队列来简化程序 下面是一个经典的生产者消费者的例子: 假设使用缓冲区存储整数,缓冲区的大小是受限制的.缓冲区提供wri ...