avatar
win8安装输入法# PDA - 掌中宝
s*a
1
这种情况必须申请返美证么?知道很多绿卡在中国工作的朋友都只是每年回美国一次度
假就可以维持绿卡身份。但是听说海关对年轻人这方面比较松,对老人就查得比较严。
如果发现在中国居住时间超过在美国时间是不是会吊销绿卡?
avatar
p*9
2
有一个问题请教论坛里的脚本语言和编程高手。
今有两个文件:文件A里面有100个关键词,文件B里面有5000行的文本。任务是在文件B
中查找文件A里的关键词,如果文件A里的关键词出现在文件B中,则把该关键词输入到
文件C中。请问如何实现?
文件A(关键词):
----------------------------------------
Apple
Banana
Can
Delta
...
----------------------------------------
文件B(文本):
----------------------------------------
define: apple
get 100 Delta
...
-----------------------------------------
文件C(结果):
-----------------------------------------
Apple
Delta
-----------------------------------------
avatar
j*a
3
谁装上qq五笔了?输入法好装吗?
avatar
z*e
4
在中国一年以内都没问题,超过一年就得申请回美纸了。
avatar
c*s
5
用awk或python。

件B

【在 p*******9 的大作中提到】
: 有一个问题请教论坛里的脚本语言和编程高手。
: 今有两个文件:文件A里面有100个关键词,文件B里面有5000行的文本。任务是在文件B
: 中查找文件A里的关键词,如果文件A里的关键词出现在文件B中,则把该关键词输入到
: 文件C中。请问如何实现?
: 文件A(关键词):
: ----------------------------------------
: Apple
: Banana
: Can
: Delta

avatar
q*q
6
fgrep -i -f fileA fileB
avatar
p*9
7
grep -i -of fileA.txt fileB.txt > fileC.txt
用Windows Notepad 打开,发现关键词都挤到一块了,请问如何分行,或者空格?
fileC.txt
-------------------
appleDelta
-------------------
avatar
r*o
8
一定要Windows么?在Linux下面,试试这个
grep -f file_A.txt file_B.txt > file_C.txt

【在 p*******9 的大作中提到】
: grep -i -of fileA.txt fileB.txt > fileC.txt
: 用Windows Notepad 打开,发现关键词都挤到一块了,请问如何分行,或者空格?
: fileC.txt
: -------------------
: appleDelta
: -------------------

avatar
l*s
9
use a better editor that is unix-format aware.

【在 p*******9 的大作中提到】
: grep -i -of fileA.txt fileB.txt > fileC.txt
: 用Windows Notepad 打开,发现关键词都挤到一块了,请问如何分行,或者空格?
: fileC.txt
: -------------------
: appleDelta
: -------------------

avatar
p*9
10
用VIM发现问题消失了,换行正确。
但如果关键词在fileB中重复出现的话,输出结果也会重复出现关键字。
请问如何避免这种重复?
文件A(关键词):
----------------------------------------
Apple
Banana
Can
Delta
...
----------------------------------------
文件B(文本):
----------------------------------------
define: apple
get 100 Delta
define: apple
get 100 Delta
...
-----------------------------------------
文件C(结果):
-----------------------------------------
apple
Delta
apple
Delta
-----------------------------------------
avatar
S*I
11
grep -i -of fileA.txt fileB.txt | sort | uniq > fileC.txt

【在 p*******9 的大作中提到】
: 用VIM发现问题消失了,换行正确。
: 但如果关键词在fileB中重复出现的话,输出结果也会重复出现关键字。
: 请问如何避免这种重复?
: 文件A(关键词):
: ----------------------------------------
: Apple
: Banana
: Can
: Delta
: ...

avatar
p*9
12
出错了,uniq不认识。
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Windows\system32>cd..
C:\Windows>cd..
C:\>D:
D:\> grep -i -of fileA.txt fileB.txt | sort | uniq > fileC.txt
'uniq' is not recognized as an internal or external command,
operable program or batch file.
======================================
已经搞定了,需要安装 CoreUtils for Windows
avatar
S*I
13
So you're using Windows; then why you post you question in Apple board?
Unfortunately, Windows batch doesn't have an easy solution for what you
want as *NIX. You probably need at least Windows Powershell.

【在 p*******9 的大作中提到】
: 出错了,uniq不认识。
: Microsoft Windows [Version 6.1.7601]
: Copyright (c) 2009 Microsoft Corporation. All rights reserved.
: C:\Windows\system32>cd..
: C:\Windows>cd..
: C:\>D:
: D:\> grep -i -of fileA.txt fileB.txt | sort | uniq > fileC.txt
: 'uniq' is not recognized as an internal or external command,
: operable program or batch file.
: ======================================

avatar
l*s
14
probably he is running windows on top of apple hardware.Not uncommon :-),

【在 S**I 的大作中提到】
: So you're using Windows; then why you post you question in Apple board?
: Unfortunately, Windows batch doesn't have an easy solution for what you
: want as *NIX. You probably need at least Windows Powershell.

avatar
p*o
15
keywords = set(
line.strip() for line in file('A.txt')
)
words = set(
file('B.txt').read().replace('\n', ' ').split(' ')
)
with open('C.txt', 'w') as f:
f.write('\n'.join(keywords & words))

件B

【在 p*******9 的大作中提到】
: 有一个问题请教论坛里的脚本语言和编程高手。
: 今有两个文件:文件A里面有100个关键词,文件B里面有5000行的文本。任务是在文件B
: 中查找文件A里的关键词,如果文件A里的关键词出现在文件B中,则把该关键词输入到
: 文件C中。请问如何实现?
: 文件A(关键词):
: ----------------------------------------
: Apple
: Banana
: Can
: Delta

avatar
l*n
16
LOL。兄弟,你用windows也得先跟大家打个招呼不是。。。

【在 p*******9 的大作中提到】
: 出错了,uniq不认识。
: Microsoft Windows [Version 6.1.7601]
: Copyright (c) 2009 Microsoft Corporation. All rights reserved.
: C:\Windows\system32>cd..
: C:\Windows>cd..
: C:\>D:
: D:\> grep -i -of fileA.txt fileB.txt | sort | uniq > fileC.txt
: 'uniq' is not recognized as an internal or external command,
: operable program or batch file.
: ======================================

avatar
w*2
17
应该罚包子。

【在 l**n 的大作中提到】
: LOL。兄弟,你用windows也得先跟大家打个招呼不是。。。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。