Forgot password
 Register account
View 192|Reply 6

[Windows] 复制文件到剪贴板

[Copy link]

3211

Threads

7832

Posts

52

Reputation

Show all posts

hbghlyj posted 2022-8-15 17:01 |Read mode
Last edited by hbghlyj 2022-9-24 19:23simple 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

82

Posts

5

Reputation

Show all posts

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

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

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

type scp.go | grep main | clip

3211

Threads

7832

Posts

52

Reputation

Show all posts

original poster hbghlyj posted 2022-8-15 22:45
Last edited by hbghlyj 2022-8-18 17:38
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 2022-8-16 09:12

17

Threads

82

Posts

5

Reputation

Show all posts

uk702 posted 2022-8-16 10:30
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

82

Posts

5

Reputation

Show all posts

uk702 posted 2022-8-16 16:47
Last edited by uk702 2022-8-16 18:18关于“抽取包含特定字符串的行拷贝剪贴板中”,若使用 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

3211

Threads

7832

Posts

52

Reputation

Show all posts

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

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

Quick Reply

Advanced Mode
B Color Image Link Quote Code Smilies
You have to log in before you can reply Login | Register account

$\LaTeX$ formula tutorial

Mobile version

2025-7-20 05:59 GMT+8

Powered by Discuz!

Processed in 0.015000 seconds, 31 queries