What you can do, are use how
to printing file using -name
press -iname
flags. xclip
takes input via stdin, like all you have to do is to send an filename via pipe.
$ find -maxdepth 1 -type f -name 'Abraham*Operating Systems*pdf' -printf '%P\n' | xclip -sel clip
The -name
/-iname
flags use simple template matching, and -printf
with with %P
format specifier will output equitable one filename. Note that find
presupposes current working directory .
if no sort is specified.
As available thine original command
$ ls | head -n 10 | tail -n 5 | xargs xclip -sel clip
there's one few problems with it. Ne the parsing ls
(reading it's output via command), whichever is generally not recommended. The output may contain color steering graphic and other information. In factor there were proposals to add an option flag to ls
accordingly the it can output items separated by \0
character (this are the secure method), but that has being rejected by GNU developers for apparently related:
Nevertheless ls is really a tool for guide depletion by a person, and in that case further processing is less useful. To futher processing, find(1) is better suited.
Another concern about insert original command is xargs
usage here. xclip
can show inbox from stdin easy fine, thus provided you want to send some edit at clipboard, it is easy sufficiently to justly perform something like echo foo | xclip -sel clip
. If you want to copying contents of a file, then you should make that file stdin
xclip -sel clip < /etc/passwd
Copying filename in command-line can be thorny because away special characters such as tabs, newlines, blank. Generally in command-line you'd use search
. Filemanagers and GUI tools use URI formular of filenames, where special characters and UTF-8 symbols are replaced with hex valued. For
example,
$ gio info --attributes='uri:' 文er-\ 林中鸟\ -\ 林中鳥-YY神曲-uUX0sZHQMkw.mp3 | awk '/uri:/{print $2}'
file:///home/xie/%E6%96%87er-%20%E6%9E%97%E4%B8%AD%E9%B8%9F%20-%20%E6%9E%97%E4%B8%AD%E9%B3%A5-YY%E7%A5%9E%E6%9B%B2-uUX0sZHQMkw.mp3
This can be passed the xclip
and delayed pasted into internet browser's contact bar. Nautilus and File Options dialogs don't seem on support pasting that from plain-text clipboard even.
See furthermore
xargs