【unix学习】文件处理2—文件sort、cut命令
2017-11-03 00:45
351 查看
文件sort、cut命令
文件sortcut命令文件排序-sort
sort
options
cut 定位符
文件排序-sort
sort
Ordering a set of items according to some criteriaoptions
b Ignore leading blanksf Consider lowercases and uppercase letters to be equivalent
t field separator
r Sort in reverse order
k Specify a field as the sort key
n Compare according to string numerical value
Notice the LANG!
对某一列排序
默认是以空格划分
sort -k index file
index 为文件中的列
把该列当作字符来比较
2. 把该列当作数字来比较
-n
sort -nk -4 file
3.逆序
-r
sort -rnk -4 file
4.字段分隔符
指定分隔符 -t
[s14516@gdufs]$sort -t: -nk4 /tmp/student_record
对于排序,要注意文件的语言
echo $LANG
cut 定位符
1.默认分隔符为定位符cut -f1 a.txt
f1 为分隔后的第一个位置的值
2. 指定字段分隔符
cut -d" " -f1 a.txt [s14516@gdufs]$cut -d":" -f1 /tmp/donors
3.截取指定位置的字符
cut -c11-19 f a.txt
相关文章推荐
- Linux学习笔记----文件处理命令---more ==分页显示文件内容
- 【unix学习】文件处理1—查看、统计、压缩、查找文件
- centos shell基础 alias 变量单引号 双引号 history 错误重定向 2>&1 jobs 环境变量 .bash_history source配置文件 nohup & 后台运行 cut,sort,wc ,uniq ,tee ,tr ,split, paste cat> 2.txt <<EOF 通配符 glob模式 发邮件命令mail 2015-4-8 第十二节课
- 文件的排序、截取和合并--sort,cut,tr等命令应用
- Linux学习之文件处理命令(二)目录处理命令 && 文件处理命令
- 0219自学Linux_bash特性+命令学习(cut,sort,uniq,wc,tr,histroy,alias)+通配符glob
- Linux学习笔记---文件处理命令--less ==显示文件内容
- linux学习笔记----文件处理命令--head= 显示文件前几行内容
- 文件的排序和合并--sort,cut,tr等命令应用
- 【unix学习】文件处理3—正则表达式和grep命令
- Linux学习(五)-----选取命令(cut grep)和排序命令(sort wc uniq)
- 【unix学习】文件处理4—sed + wget + awk命令
- iconv内容,convmv文件名,unix2dos,dos2unix文件格式转换,od/cut/wc/dd/diff/uniq/nice/du等命令,linux文件名乱码,文件名,文件内容,vim编码设置
- Linux学习笔记----文件处理命令----touch ---创建文件
- Linux学习笔记----文件处理命令--cat ==显示文件内容
- 文本文件操作命令cut wc sort uniq tr
- 文件及文本管理命令 cp,cut,sort,uniq,tr详解
- 文本文件命令(wc,cut,sort,uniq)及常用参数
- iconv内容,convmv文件名,unix2dos,dos2unix文件格式转换,od/cut/wc/dd/diff/uniq/nice/du等命令,linux文件名乱码,文件名,文件内容,vim编码设置
- linux学习第二十五篇:cut,sort,wc,uniq,tee,tr,split命令,shell特殊符号