如何在文件中获取特定单词? [英] How to get a specific word in a file?

查看:85
本文介绍了如何在文件中获取特定单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




如何获取文件中的特定行/单词。


Ex:

$ cat my_file.txt

1

2

3

4

5

6

7


我想得到7在文件my_file.txt中。 Tnx。


-coax



how can i get the particular line/word in the file.

Ex:
$ cat my_file.txt
1
2
3
4
5
6
7

I want to get the "7" in the file my_file.txt. Tnx.


-coax

推荐答案

cat my_file.txt

1

2

3

4

5

6

7


我想得到7在文件my_file.txt中。 Tnx。


-coax
cat my_file.txt
1
2
3
4
5
6
7

I want to get the "7" in the file my_file.txt. Tnx.


-coax


我想有一百万种方法可以做到这一点。命令行:


cat file.txt | grep7


将获得 7,但是在你获得之后你想用7做什么?它?
I suppose there is a million ways to do this. The command line:

cat file.txt | grep "7"

would "get" the 7, but what do you want to do with the 7 after you "get" it?


我想要的是拥有那条特定的线?

我故意使用AWK,但我希望将输入作为我的搜索文本。 />
这就是我的意思,


What I want is to have exactly that specific line?
Intentionally I used AWK but I want to have my input as my search text.
this is what exactly what i mean,



这篇关于如何在文件中获取特定单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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