作者:潮流Fee_750 | 来源:互联网 | 2023-10-12 18:30
SupposeIhaveatextfilewithdataseparatedbywhitespaceintocolumns.Iwanttowriteashells
Suppose I have a text file with data separated by whitespace into columns. I want to write a shell script which takes as input a filename and a number N and prints out only that column. With awk I can do the following:
假设我有一个文本文件,其中的数据由空格分隔成列。我想编写一个shell脚本,它将文件名和数字N作为输入,只打印出该列。使用awk我可以执行以下操作:
awk /tmp/out
This code prints out the second column.
此代码打印出第二列。
But how would one wrap that in a shell script so that a arbitrary column could be passed in argv?
但是如何在shell脚本中包装它以便在argv中传递任意列?
2 个解决方案