What is the command line equivalent of copying a file to clipboard? [duplicate]


When you press Ctrl-C over a file in the file manager, the file's contents IS NOT copied to the clipboard. A simple test: select a file in file manager, press Ctrl-C, open a text editor, press Ctrl-V. The result is not file's contents but its full path.

In reality the situation is a bit more complicated because you can't do the opposite - copy a list of filenames from a text editor and paste them into file manager.

To copy some data from command line to X11 clipboard you can use xclip command, which can be installed with

sudo apt-get install xclip

to copy contents of a file or output of some command to clipboard use

cat ./myfile.txt|xclip -i

the text can be then pasted somewhere using middle mouse button (this is called "primary selection buffer").

If you want to copy data to the "clipboard" selection, so it can be pasted into an application with Ctrl-V, you can do

cat ./myfile.txt|xclip -i -selection clipboard

To be able to copy files from...

0 0

You can try Swiss File Knife (SFK):

sfk toclip Copy stdin to clipboard as plain text. type test.txt | sfk toclip Copies the content of ASCII file test.txt into the clipboard. sfk list | sfk toclip Copies a file listing of the current dir into the clipboard. sfk fromclip [-wait] [-clear] Dump plain text content from the clipboard to the terminal. -wait : block until plain text is available. -clear: empty the clipboard after reading it.

Example: turn backslashes into forward slashes. Imagine you have the following text open within Notepad:

foo/bar/systems/alpha1.cpp foo/bar/systems/alpha2.cpp foo/bar/systems/beta1.cpp

And for some reason you need the first line in a format like this:


Then you may do it this way:

Mark the first line using SHIFT + CURSOR keys. Press Ctrl + C or Ctrl + Insert to copy it into clipboard

On the Windows command line, run this command (for example, from a batch file):

sfk fromclip...
0 0

Use this program f2clip. Run it from the command line. It copies file contents into clipboard. I use it for copying text files into web browser for further processing. Download it from http://smrz.xf.cz/f2clip.exe or write your own from this source (it's ugly):

program f2clip; {$APPTYPE CONSOLE} uses SysUtils, clipbrd; var i,r:integer; s:string; f:file; buf:array[0..1024*1024-1] of byte; data:string; d:pointer; begin try { TODO -oUser -cConsole Main : Insert code here } if (paramcount=0) then begin writeln('parameters: f2clip filename.txt'); end else begin write('parameter count: '); writeln(paramcount); for i:=1 to paramcount do begin s:=paramstr(i); writeln('file: ',s); assignfile(f,s); reset(f,1); BlockRead(f,buf,1024*1024,r); writeln('size: ',r); buf[r]:=0; d:=@(buf[0]); data:=PAnsiChar(d); Clipboard.AsText := data; close(f); end; end; except on E:Exception do Writeln(E.Classname, ': ', E.Message); end; end....
0 0

Yes. Hit Ctrl-R then ". If you have literal control characters in what you have yanked, use Ctrl-R, Ctrl-O, ".

Here is an explanation of what you can do with registers. What you can do with registers is extraordinary, and once you know how to use them you cannot live without them.

Registers are basically storage locations for strings. Vim has many registers that work in different ways:

See :help registers for the full reference.

You can, at any moment, use :registers to display the contents of all registers. Synonyms and shorthands for this command are :display, :reg and :di.

In Insert or Command-line mode, Ctrl-R plus a register name, inserts the contents of this register. If you want to insert them literally (no auto-indenting, no conversion of control characters like 0x08 to backspace, etc), you can use Ctrl-R, Ctrl-O, register name. See :help i_CTRL-R and following paragraphs for more reference.

But you can also do the following (and I...

0 0

How to copy the ex command to the clipboard or paste it to the buffer?

Using gvim on Windows.

How to copy to clipboard using vim?

Is it possible to copy to clipboard directly from vim? yy only copies stuff to vim’s internal buffer. I want to copy to the OS’s clipboard. Is there any such command in vim or you can only yank stuff

Run bash command on Vim and copy result to clipboard

How can I create a Vim command and copy it’s results to clipboard? I want to convert Markdown to HTML and copy the result to the clipboard. So far I got: nmap md :%!/bin/markdown/Markdown.pl –html4ta

Copying current Vim buffer into clipboard [duplicate]

This question already has an answer here: VI Editor : Yank the entire file to clipboard (specific to OS X) 3 answers I am trying to copy Vim’s buffer to clipboard and I did the following: :!cat

Copy Vim Version Information to Clipboard

I am using gvim 7.3 on Windows 7 64 bit Professional....

0 0

I needed to upload the contents of a lengthy log file to a site earlier today. There was no option to simply attach the file. I was instead asked to just paste its contents. I suppose that I could have opened the file in an editor like Kate and copied its contents to the clipboard. But I became curious as to the possibility of accomplishing this from within the terminal. A little googling revealed the existence of a utility named xsel for this very purpose.

The utility will first need to be installed:
sudo apt-get install xsel
(on my Debian-based distro)

Once this is one, copying the contents of the file to the clipboard is as simple as:
cat myfile.log | xsel

The file is now in the (X) clipboard/buffer and can be pasted in the browser by way of a mouse middle-click or an equivalent command.

Nifty and I hope that you like...

0 0

Brief: FSlint is a great GUI tool to find duplicate files in Linux and remove them. FDUPES also find the files with same name in Linux but in the command line way.

If you have this habit of downloading everything from the web like me, you will end up having multiple duplicate files. Most often, I can find the same songs or a bunch of images in different directories or end up backing up some files at two different places. It’s a pain locating these duplicate files manually and deleting them to recover the disk space.

If you want to save yourself from this pain, there are various Linux applications that will help you in locating these duplicate files and removing them. In this article, we will cover how you can find and remove these files in Ubuntu.

Note: You should know what you are doing. If you are using a new tool, it’s always better to try it in a virtual directory structure to figure out what it does before taking it to root or home folder. Also,...

0 0

If you've ever been debugging with a fellow developer, you'll hear "OK, execute that and let me know what it says". In this case, you can either manually copy the output and instant message the text over to them, or you can write the output to file with >> , open the file, manually copy the contents, and paste it into IM. I experience this for a few hours recently and it was way to much work! Shouldn't there be a way to quickly place an execution's output directly into the clipboard just to save some time? You can with pbcopy!

Copy stdout to Clipboard

You'll use a single pipe to transfer the stdout result into the clipboard:

# command | pbcopy hg diff | pbcopy

The git diff information is copied to the clipboard in this example; now you can show your colleague what you've changed.

Copy File Contents to Clipboard

In the case of copying file contents into the clipboard, pbcopy goes first:

# pbcopy < file.ext pbcopy < circle.yml


0 0

In a GUI file manager it is possible to select a few files, press Ctrl-C (which supposedly copies come info about the files to clipboard), then navigate to another folder and press Ctrl-V, which will then copy the files into that directory.

As an experiment, after copying files in the file manager, it is possible to switch to a text editor - pressing Ctrl-V there pastes a list of absolute filenames. The reverse process (copying a list of files from a text editor and pasting them to a file manager) does not work, which is supposedly due to different target atoms

The goal of the exercise is to be able to copy some files from command line, for example

find ${PWD} -name "*.txt" | xclip

then switch to a file manager and copy them all to a directory using File->Paste.

So, the question is: What parameters of xclip (or other program) do I need to specify so file manager recognizes the selection as a list of files and enables its Paste menu...

0 0

I have this for Windows, but there should be a cross-platform solution.

//This works on Vista and Win 7, XP requires the user to copy 'clip.exe' to the 'sys32' folder.

function copyTextToClipboard2(text)


var folderForTempFiles = Folder.temp.fsName;


// create a new textfile and put the text into it

var clipTxtFile =new File(folderForTempFiles + "/ClipBoard.txt");




// use the clip.exe to copy the contents of the textfile to the windows clipboard

var clipBatFile =new File(folderForTempFiles + "/ClipBoard.bat");


clipBatFile.writeln("clip < " + folderForTempFiles + "/ClipBoard.txt");



0 0

Aha! Simple, you say. Just go to the graphical interface you’re using for your Linux system. Then you can quickly and easily move the file of your choice from one place to another, copy it, or zap it into nothingness.

Now, what if you wanted to move (or copy or delete) many files at the same time? In particular, what if you wanted to move all files with the same characters at the end of their name, like joe_expenses, cath_expenses, mike_expenses and robin_expenses?

In the case mentioned above, the Linux command line offers far greater power and efficiency than the GUI. For instance, to instantly seek out and move all of the files above to a subdirectory called budget, your command line instruction would simply be:

Each of the Linux commands to move, copy, or delete files have options to make it more productive. Read on to find out more.

1. mv: Moving (and Renaming) Files

The mv command lets you move a file from one directory location to another....

0 0

Most longtime command line users rely on the cp command to copy files and directories, but Mac OS X offers another solution with the ‘ditto’ command. Ditto is slightly more advanced but can be advantageous to ‘cp’ for several reasons, as it not only preserves ownership attributes and permissions but also file resource forks and file and folder metadata, essentially insuring that the file and/or folders are copied exactly. Additionally, ditto can be used to copy a file or folder to a source directory, but if that source doesn’t yet exist, ditto will automatically create it. Also, if the destination folder does exist, the copied contents will be merged together in that destination directory. Finally, ditto also follows symbolic links, making it particularly handy if you’re a heavy user of the ln command.

To better understand the ditto command, let’s run through a few examples with real syntax.

Using Ditto to Copy Files / Folders

At it’s most simple form, ditto...

0 0