Forgot password?
 Create new account
View 147|Reply 6

[Windows] 复制文件到剪贴板

[Copy link]

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2022-8-15 17:01:23 |Read mode
Last edited by hbghlyj at 2022-9-24 19:23:00simple command line tool to copy file into windows clipboard
可以直接下载file2clip.exe, 或者运行csc.exe file2clip.cs编译.
编译信息:
file2clip.cs(56,21): warning CS0168: The variable 'e' is declared but never used
这好像是指第56行的 catch (Exception e) 吗?

17

Threads

126

Posts

1822

Credits

Credits
1822

Show all posts

uk702 Posted at 2022-8-15 19:10:53
干什么用的?windows 应该内置了一个 clip.exe,如下命令可将某文件 copy 到剪贴板中。

cat a.txt | clip
type a.txt | clip

如果再加上 head/tail/grep/awk/... 之类的东西,完全可以变戏法了,如:

type scp.go | grep main | clip

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2022-8-15 22:45:25
Last edited by hbghlyj at 2022-8-18 17:38:00
uk702 发表于 2022-8-15 12:10
如果再加上 head/tail/grep/awk/... 之类的东西,完全可以变戏法了,如:

type scp.go | grep main | clip
grep应是Linux内置的, 在Windows命令行的等效是findstr吧
另外cat应是Linux内置的, 不是Windows吧

Comment

装个 git(你不会没装吧?),其中包含了 cat、grep 等很多 unix 工具。 或者安装 gnuwin32 for windows ,什么都有了。  Posted at 2022-8-16 09:12

17

Threads

126

Posts

1822

Credits

Credits
1822

Show all posts

uk702 Posted at 2022-8-16 10:30:24
uk702 发表于 2022-8-15 19:10
干什么用的?windows 应该内置了一个 clip.exe,如下命令可将某文件 copy 到剪贴板中。

cat a.txt | clip  ...
曾经有一段时间为如何抽取包含特定字符串的行拷贝剪贴板中,没想到就这么简单地解决了:
awk "/xxx/" foo.txt | clip 或 type foo.txt | grep xxx | clip

17

Threads

126

Posts

1822

Credits

Credits
1822

Show all posts

uk702 Posted at 2022-8-16 16:47:55
Last edited by uk702 at 2022-8-16 18:18:00关于“抽取包含特定字符串的行拷贝剪贴板中”,若使用 vim,可使用如下方法:
:g/xxx/let @+=@+.getline(".")."\n"

但略嫌麻烦一些,不知大家有没有更好的方法?

经测试,如下命令,:g/xxx/"Ayy 没有效果,但 :g/xxx/normal "Ayy 却好使。

Rate

Number of participants 1威望 +1 Collapse Reason
hbghlyj + 1 谢谢分享

View Rating Log

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2022-8-18 01:18:22
uk702 发表于 2022-8-15 12:10
干什么用的?windows 应该内置了一个 clip.exe,如下命令可将某文件 copy 到剪贴板中。

cat a.txt | clip  ...
好像不是一个功能... 1#似乎是将文件复制到剪贴板, 在explorer(资源管理器)中可以粘贴到其他位置, 在记事本中粘贴无效.

手机版Mobile version|Leisure Math Forum

2025-4-20 22:23 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list