如何运行多个Unix命令? [英] How do I run multiple Unix commands?

查看:159
本文介绍了如何运行多个Unix命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我必须立即运行一个剪切和一个排序文件。我使用此命令:

So I have to run a cut and a sort file at once. I'm using this command:

排序-k2客户;删除-f7-31客户

目标是剪切线7-31,然后按字母顺序组织它们,但我不知道如何实现它。任何输入都会有帮助,谢谢。

The objective is to cut lines 7-31 then organize them in alphabetical order but I am not sure how to achieve it. Any input will help, thank you.

推荐答案


目标是剪切线7-31。 ..

The objective is to cut lines 7-31 ...

您可以使用 sed

sort -k2 customers | sed '7,31!d'

这将管道输出 sort c>到 sed ,它将从 sort 输出显示第7 - 31行

This would pipe the output of sort to sed which would display lines 7 - 31 (both inclusive) from the sort output.

为了选择字符范围,您需要提供 -c 选项而不是 -f (可选择字段):

In order to select a character range, you need to supply the -c option to cut and not -f (which selects fields):

sort -k2 customers | cut -c7-31

这将从<$ c $中选择字符7 - 31 c> sort 输出。

code>最后输出,使用另一个管道:

In order to sort the final output, use another pipeline:

sort -k2 customers | cut -c7-31 | sort

这篇关于如何运行多个Unix命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆