🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 169 (from laksa194)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

đź“„
INDEXABLE
âś…
CRAWLED
16 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.6 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal
Last Crawled2026-04-01 07:55:16 (16 days ago)
First Indexed2021-04-03 21:46:29 (5 years ago)
HTTP Status Code200
Meta Titlessh - Copy file contents to the clipboard in Linux terminal - Stack Overflow
Meta Descriptionnull
Meta Canonicalnull
Boilerpipe Text
xclip -sel c < input_file will copy the contents of input_file to clipboard. xclip requires installation. To install sudo apt install xclip -sel stands for -selection . c is for clipboard . Interchangeable. Capable of much more, I advise reading its man page. There is also xsel . This answer on Unix SE gives a very thorough answer to this exact question.
Markdown
# ![site logo](https://stackoverflow.com/Content/Img/SE-logo75.png) By clicking “Sign up”, you agree to our [terms of service](https://stackoverflow.com/legal/terms-of-service/public) and acknowledge you have read our [privacy policy](https://stackoverflow.com/legal/privacy-policy). # OR Already have an account? [Log in](https://stackoverflow.com/users/login) [Skip to main content](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#content) [Stack Overflow](https://stackoverflow.com/) 1. [About](https://stackoverflow.co/) 2. Products 3. [For Teams](https://stackoverflow.co/internal/) 1. [Stack Internal Implement a knowledge platform layer to power your enterprise and AI tools.](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams) 2. [Stack Data Licensing Get access to top-class technical expertise with trusted & attributed content.](https://stackoverflow.co/data-licensing/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api) 3. [Stack Ads Connect your brand to the world’s most trusted technologist communities.](https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising) 4. [Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal.](https://stackoverflow.blog/releases/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=releases) 5. [About the company](https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company) [Visit the blog](https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog) 1. ### [current community](https://stackoverflow.com/) - [Stack Overflow](https://stackoverflow.com/) [help](https://stackoverflow.com/help) [chat](https://chat.stackoverflow.com/?tab=explore) - [Meta Stack Overflow](https://meta.stackoverflow.com/) ### your communities [Sign up](https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F32039476%2Fcopy-file-contents-to-the-clipboard-in-linux-terminal) or [log in](https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F32039476%2Fcopy-file-contents-to-the-clipboard-in-linux-terminal) to customize your list. ### [more stack exchange communities](https://stackexchange.com/sites) [company blog](https://stackoverflow.blog/) 2. [Log in](https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F32039476%2Fcopy-file-contents-to-the-clipboard-in-linux-terminal) 3. [Sign up](https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F32039476%2Fcopy-file-contents-to-the-clipboard-in-linux-terminal) # Let's set up your homepage Select a few topics you're interested in: python javascript c\# reactjs java android html flutter c++ node.js typescript css r php angular next.js spring-boot machine-learning sql excel ios azure docker Or search from our full list: - javascript - python - java - c\# - php - android - html - jquery - c++ - css - ios - sql - mysql - r - reactjs - node.js - arrays - c - asp.net - json - python-3.x - .net - ruby-on-rails - sql-server - swift - django - angular - objective-c - excel - pandas - angularjs - regex - typescript - ruby - linux - ajax - iphone - vba - xml - laravel - spring - asp.net-mvc - database - wordpress - string - flutter - postgresql - mongodb - wpf - windows - xcode - amazon-web-services - bash - git - oracle-database - spring-boot - dataframe - azure - firebase - list - multithreading - docker - vb.net - react-native - eclipse - algorithm - powershell - macos - visual-studio - numpy - image - forms - scala - function - vue.js - performance - twitter-bootstrap - selenium - winforms - kotlin - loops - express - dart - hibernate - sqlite - matlab - python-2.7 - shell - rest - apache - entity-framework - android-studio - csv - maven - linq - qt - dictionary - unit-testing - asp.net-core - facebook - apache-spark - tensorflow - file - swing - class - unity-game-engine - sorting - date - authentication - go - symfony - t-sql - opencv - matplotlib - .htaccess - google-chrome - for-loop - datetime - codeigniter - perl - http - validation - sockets - google-maps - object - uitableview - xaml - oop - visual-studio-code - if-statement - cordova - ubuntu - web-services - email - android-layout - github - spring-mvc - elasticsearch - kubernetes - selenium-webdriver - ms-access - ggplot2 - user-interface - parsing - pointers - google-sheets - c++11 - security - machine-learning - google-apps-script - ruby-on-rails-3 - templates - flask - nginx - variables - exception - sql-server-2008 - gradle - debugging - tkinter - delphi - listview - jpa - asynchronous - web-scraping - haskell - pdf - jsp - ssl - amazon-s3 - google-cloud-platform - jenkins - testing - xamarin - wcf - batch-file - generics - npm - ionic-framework - network-programming - unix - recursion - google-app-engine - mongoose - visual-studio-2010 - .net-core - android-fragments - assembly - animation - math - svg - rust - session - intellij-idea - hadoop - join - curl - winapi - django-models - next.js - laravel-5 - url - heroku - http-redirect - tomcat - google-cloud-firestore - inheritance - webpack - gcc - image-processing - swiftui - keras - asp.net-mvc-4 - logging - dom - matrix - pyspark - actionscript-3 - button - post - optimization - firebase-realtime-database - web - jquery-ui - cocoa - xpath - iis - d3.js - javafx - firefox - xslt - internet-explorer - caching - select - asp.net-mvc-3 - opengl - events - asp.net-web-api - plot - dplyr - encryption - magento - stored-procedures - search - amazon-ec2 - ruby-on-rails-4 - memory - canvas - multidimensional-array - audio - random - jsf - vector - redux - cookies - input - facebook-graph-api - flash - indexing - xamarin.forms - arraylist - ipad - cocoa-touch - data-structures - video - model-view-controller - azure-devops - serialization - apache-kafka - jdbc - razor - woocommerce - awk - routes - servlets - mod-rewrite - excel-formula - beautifulsoup - filter - iframe - docker-compose - design-patterns - aws-lambda - text - visual-c++ - django-rest-framework - cakephp - mobile - android-intent - struct - react-hooks - methods - groovy - mvvm - lambda - ssh - checkbox - time - ecmascript-6 - grails - google-chrome-extension - installation - cmake - sharepoint - shiny - spring-security - jakarta-ee - plsql - android-recyclerview - core-data - types - sed - meteor - android-activity - bootstrap-4 - activerecord - websocket - graph - replace - group-by - scikit-learn - vim - file-upload - boost - junit - memory-management - sass - async-await - import - deep-learning - error-handling - eloquent - dynamic - soap - dependency-injection - silverlight - layout - apache-spark-sql - charts - deployment - browser - gridview - svn - while-loop - google-bigquery - vuejs2 - highcharts - dll - ffmpeg - view - foreach - makefile - plugins - redis - c\#-4.0 - reporting-services - jupyter-notebook - unicode - merge - reflection - https - server - google-maps-api-3 - twitter - oauth-2.0 - extjs - terminal - axios - pip - split - cmd - pytorch - encoding - django-views - collections - database-design - hash - netbeans - automation - data-binding - ember.js - build - tcp - pdo - sqlalchemy - apache-flex - entity-framework-core - concurrency - mysqli - command-line - spring-data-jpa - printing - react-redux - java-8 - lua - html-table - neo4j - ansible - service - jestjs - parameters - enums - flexbox - material-ui - module - promise - visual-studio-2012 - outlook - web-applications - firebase-authentication - webview - uwp - jquery-mobile - utf-8 - datatable - python-requests - parallel-processing - colors - drop-down-menu - scipy - scroll - tfs - hive - count - syntax - ms-word - twitter-bootstrap-3 - ssis - fonts - rxjs - constructor - google-analytics - file-io - paypal - three.js - powerbi - graphql - cassandra - discord - graphics - compiler-errors - gwt - socket.io - react-router - backbone.js - solr - memory-leaks - url-rewriting - datatables - nlp - terraform - oauth - datagridview - drupal - zend-framework - oracle11g - triggers - knockout.js - neural-network - interface - django-forms - angular-material - casting - jmeter - linked-list - google-api - path - timer - arduino - django-templates - orm - proxy - directory - windows-phone-7 - parse-platform - visual-studio-2015 - cron - conditional-statements - push-notification - functional-programming - primefaces - pagination - model - jar - xamarin.android - hyperlink - uiview - vbscript - visual-studio-2013 - google-cloud-functions - azure-active-directory - gitlab - jwt - download - swift3 - sql-server-2005 - process - pygame - configuration - rspec - properties - callback - combobox - windows-phone-8 - linux-kernel - safari - scrapy - permissions - emacs - x86 - clojure - scripting - raspberry-pi - io - scope - azure-functions - expo - compilation - responsive-design - mongodb-query - nhibernate - angularjs-directive - reference - request - binding - bluetooth - dns - architecture - playframework - pyqt - 3d - version-control - discord.js - doctrine-orm - package - f\# - rubygems - get - sql-server-2012 - autocomplete - tree - openssl - datepicker - kendo-ui - jackson - yii - controller - grep - nested - xamarin.ios - static - null - transactions - statistics - active-directory - datagrid - dockerfile - uiviewcontroller - webforms - sas - discord.py - computer-vision - phpmyadmin - notifications - duplicates - mocking - pycharm - youtube - yaml - nullpointerexception - menu - blazor - sum - plotly - bitmap - visual-studio-2008 - asp.net-mvc-5 - floating-point - yii2 - css-selectors - stl - electron - android-listview - jsf-2 - time-series - cryptography - ant - hashmap - character-encoding - stream - msbuild - asp.net-core-mvc - sdk - google-drive-api - jboss - selenium-chromedriver - joomla - devise - navigation - cors - cuda - anaconda - frontend - background - multiprocessing - binary - pyqt5 - camera - iterator - linq-to-sql - mariadb - onclick - android-jetpack-compose - ios7 - microsoft-graph-api - android-asynctask - rabbitmq - tabs - amazon-dynamodb - laravel-4 - environment-variables - uicollectionview - insert - linker - xsd - coldfusion - console - continuous-integration - upload - textview - ftp - opengl-es - macros - operating-system - mockito - localization - formatting - xml-parsing - json.net - vuejs3 - type-conversion - data.table - kivy - timestamp - integer - calendar - segmentation-fault - android-ndk - prolog - drag-and-drop - char - crash - jasmine - automated-tests - geometry - azure-pipelines - dependencies - fortran - android-gradle-plugin - itext - sprite-kit - mfc - header - attributes - firebase-cloud-messaging - nosql - format - nuxt.js - odoo - db2 - jquery-plugins - event-handling - julia - jenkins-pipeline - leaflet - annotations - flutter-layout - nestjs - keyboard - postman - textbox - arm - visual-studio-2017 - stripe-payments - gulp - libgdx - uikit - synchronization - timezone - azure-web-app-service - dom-events - xampp - wso2 - crystal-reports - google-sheets-formula - namespaces - aggregation-framework - swagger - android-emulator - jvm - uiscrollview - sequelize.js - chart.js - com - snowflake-cloud-data-platform - subprocess - geolocation - webdriver - html5-canvas - garbage-collection - sql-update - centos - dialog - concatenation - numbers - widget - qml - tuples - set - java-stream - mapreduce - ionic2 - smtp - windows-10 - rotation - android-edittext - modal-dialog - nuget - spring-data - radio-button - doctrine - http-headers - grid - lucene - sonarqube - xmlhttprequest - listbox - switch-statement - initialization - internationalization - components - boolean - apache-camel - google-play - gdb - serial-port - ios5 - ldap - return - youtube-api - pivot - latex - eclipse-plugin - tags - frameworks - containers - c++17 - github-actions - subquery - dataset - asp-classic - embedded - foreign-keys - label - uinavigationcontroller - delegates - copy - struts2 - google-cloud-storage - migration - protractor - base64 - uibutton - queue - find - sql-server-2008-r2 - arguments - composer-php - append - jaxb - stack - tailwind-css - zip - cucumber - autolayout - ide - entity-framework-6 - iteration - popup - r-markdown - windows-7 - vb6 - airflow - g++ - ssl-certificate - clang - hover - jqgrid - range - gmail Next You’ll be prompted to create an account to view your personalized homepage. 1. 1. [Home](https://stackoverflow.com/) 2. [Questions](https://stackoverflow.com/questions) 3. [AI Assist](https://stackoverflow.com/ai-assist) 4. [Tags](https://stackoverflow.com/tags) 5. [Challenges](https://stackoverflow.com/beta/challenges) 6. [Chat](https://chat.stackoverflow.com/rooms/259507/stack-overflow-lobby) 7. [Articles](https://stackoverflow.blog/contributed?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=so-blog&utm_content=experiment-articles) 8. [Users](https://stackoverflow.com/users) 9. [Companies](https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav) 10. [Collectives]() 11. Communities for your favorite technologies. [Explore all Collectives](https://stackoverflow.com/collectives-all) 2. Stack Internal Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work. [Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) 3. [Stack Internal]() 4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact) ##### Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. [Learn more about Collectives](https://stackoverflow.com/collectives) **Stack Internal** Knowledge at work Bring the best of human thought and AI automation together at your work. [Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover) # [Copy file contents to the clipboard in Linux terminal \[closed\]](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal) [Ask Question](https://stackoverflow.com/questions/ask) Asked 10 years, 4 months ago Modified [1 month ago](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal?lastactivity "2025-11-11 15:41:32Z") Viewed 547k times This question shows research effort; it is useful and clear 234 Save this question. Show activity on this post. **Closed.** This question does not meet [Stack Overflow guidelines](https://stackoverflow.com/help/closed-questions). It is not currently accepting answers. *** This question does not appear to be about [a specific programming problem, a software algorithm, or software tools primarily used by programmers](https://stackoverflow.com/help/on-topic). If you believe the question would be on-topic on [another Stack Exchange site](https://stackexchange.com/sites), you can leave a comment to explain where the question may be able to be answered. Closed 5 years ago. The community reviewed whether to reopen this question last year and left it closed: > Original close reason(s) were not resolved [Improve this question](https://stackoverflow.com/posts/32039476/edit) I'm generating an SSH key but I don't know how to copy the key from `id_rsa.pub` to the clipboard. I'm using BackBox Linux. - [linux](https://stackoverflow.com/questions/tagged/linux "show questions tagged 'linux'") - [ssh](https://stackoverflow.com/questions/tagged/ssh "show questions tagged 'ssh'") [Share](https://stackoverflow.com/q/32039476 "Short permalink to this question") Share a link to this question Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this question](https://stackoverflow.com/posts/32039476/edit) Follow Follow this question to receive notifications [edited Apr 23, 2024 at 15:57](https://stackoverflow.com/posts/32039476/revisions "show all edits to this post") [![Mark Rotteveel's user avatar](https://www.gravatar.com/avatar/d873f397779db38cd510d9ee5416fd43?s=64&d=identicon&r=PG)](https://stackoverflow.com/users/466862/mark-rotteveel) [Mark Rotteveel](https://stackoverflow.com/users/466862/mark-rotteveel) 110k241241 gold badges160160 silver badges233233 bronze badges asked Aug 16, 2015 at 20:13 [![Ravi Shankar's user avatar](https://graph.facebook.com/100003332281008/picture?type=large)](https://stackoverflow.com/users/4457169/ravi-shankar) [Ravi Shankar](https://stackoverflow.com/users/4457169/ravi-shankar) 2,83544 gold badges1616 silver badges1515 bronze badges 3 - 2 For Wayland, use wl-clipboard. [superuser.com/a/1377550/137881](https://superuser.com/a/1377550/137881) Abdull – [Abdull](https://stackoverflow.com/users/923560/abdull "28,167 reputation") 2024-05-08 10:19:26 +00:00 [Commented May 8, 2024 at 10:19](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#comment138301650_32039476) - copy with vim -- [stackoverflow.com/questions/1620018/…](https://stackoverflow.com/questions/1620018/copy-all-the-lines-to-clipboard "copy all the lines to clipboard") J'e – [J'e](https://stackoverflow.com/users/2601293/je "3,886 reputation") 2024-11-26 15:51:49 +00:00 [Commented Nov 26, 2024 at 15:51](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#comment139707811_32039476) - If you want to copy directory from terminal, here's a custom command: copy() { local dir="\$1" if \[ -z "\$dir" \]; then dir="." fi local fullpath fullpath="\$(cd "\$dir" 2\>/dev/null && pwd)" if \[ -z "\$fullpath" \]; then echo "❌ Error: Could not resolve path '\$dir'" return 1 fi osascript -e "set the clipboard to (POSIX file \\"\$fullpath\\")" } hectormc – [hectormc](https://stackoverflow.com/users/21449250/hectormc "11 reputation") 2025-08-31 23:02:28 +00:00 [Commented Aug 31 at 23:02](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#comment140705783_32039476) [Add a comment](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal "Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.") \| ## 4 Answers 4 Sorted by: [Reset to default](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal?answertab=scoredesc#tab-top) This answer is useful 249 Save this answer. Show activity on this post. ``` xclip -sel c < input_file ``` will copy the contents of `input_file` to clipboard. `xclip` requires installation. To install ``` sudo apt install xclip ``` *** `-sel` stands for `-selection`. `c` is for `clipboard`. Interchangeable. Capable of much more, I advise reading its man page. There is also `xsel`. [This answer](https://unix.stackexchange.com/a/211826/122065) on Unix SE gives a very thorough answer to this exact question. [Share](https://stackoverflow.com/a/62168635 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this answer](https://stackoverflow.com/posts/62168635/edit) Follow Follow this answer to receive notifications answered Jun 3, 2020 at 8:45 [![Haggra's user avatar](https://i.sstatic.net/ZIfkF.jpg?s=64)](https://stackoverflow.com/users/4354754/haggra) [Haggra](https://stackoverflow.com/users/4354754/haggra) 4,40822 gold badges2727 silver badges2828 bronze badges Sign up to request clarification or add additional context in comments. ## 7 Comments Add a comment [![](https://i.sstatic.net/8wn0u.png?s=64)](https://stackoverflow.com/users/12172291/alexzander) alexzander [alexzander](https://stackoverflow.com/users/12172291/alexzander) [Over a year ago](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#comment120469223_62168635) if someone wants to use `alias` for this you can do this: `alias cpc="xclip -sel c < "` and you can use it like so: `cpc file_name.txt`; cpc stands for copy contents 2021-06-28T11:23:30.603Z+00:00 10 Reply - Copy link [![](https://i.sstatic.net/zy1n6.png?s=64)](https://stackoverflow.com/users/1736206/yannick-copin) Yannick Copin [Yannick Copin](https://stackoverflow.com/users/1736206/yannick-copin) [Over a year ago](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#comment124286440_62168635) Why not just `cat input_file | xclip`? 2021-12-10T18:32:32.853Z+00:00 9 Reply - Copy link [![](https://www.gravatar.com/avatar/8e9d3fd9b62d4417049eed10d89f9591?s=48&d=identicon&r=PG&f=y&so-version=2)](https://stackoverflow.com/users/3787646/multisync) Multisync [Multisync](https://stackoverflow.com/users/3787646/multisync) [Over a year ago](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#comment136126420_62168635) @YannickCopin: That would be what people refer to as "useless use of `cat`". 2023-10-02T14:33:09.663Z+00:00 4 Reply - Copy link [![](https://lh3.googleusercontent.com/-4RPtAtabThY/AAAAAAAAAAI/AAAAAAAAAAA/ABtNlbDXuYsGfgLUewwfMs5m-FdvugynGA/mo/s48-rj/photo.jpg)](https://stackoverflow.com/users/10596188/fauna-muirgen) Fauna Muirgen [Fauna Muirgen](https://stackoverflow.com/users/10596188/fauna-muirgen) [Over a year ago](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#comment137681462_62168635) "Error: Can't open display: (null)" btw it's a server there is no display 2024-03-03T17:20:11.203Z+00:00 14 Reply - Copy link [![](https://i.sstatic.net/0y5dS.png?s=64)](https://stackoverflow.com/users/3429115/rafs) Rafs [Rafs](https://stackoverflow.com/users/3429115/rafs) [Apr 7 at 15:49](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#comment140308522_62168635) `Error: Can't open display: (null)` as well. 2025-04-07T15:49:12.37Z+00:00 3 Reply - Copy link Add a comment \| Show 2 more comments This answer is useful 103 Save this answer. Show activity on this post. On macOS, you can do the following that will directly copy the content of id\_rsa.pub to clipboard: ``` pbcopy < ~/.ssh/id_rsa.pub ``` [Share](https://stackoverflow.com/a/54469770 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this answer](https://stackoverflow.com/posts/54469770/edit) Follow Follow this answer to receive notifications [edited Jun 16, 2024 at 21:56](https://stackoverflow.com/posts/54469770/revisions "show all edits to this post") [![Zoe - Save the data dump's user avatar](https://i.sstatic.net/WmJNSJwX.png?s=64)](https://stackoverflow.com/users/6296561/zoe-save-the-data-dump) [Zoe - Save the data dump](https://stackoverflow.com/users/6296561/zoe-save-the-data-dump) 28\.4k2222 gold badges130130 silver badges163163 bronze badges answered Jan 31, 2019 at 21:51 [![Yu N.'s user avatar](https://lh3.googleusercontent.com/-8OyEKmA_ewc/AAAAAAAAAAI/AAAAAAAAAAA/ACevoQMUvcS6Un85hef3Sn2UZv_WDMqwbw/mo/s64-rj/photo.jpg)](https://stackoverflow.com/users/10970151/yu-n) [Yu N.](https://stackoverflow.com/users/10970151/yu-n) 2,40311 gold badge1414 silver badges99 bronze badges ## 2 Comments Add a comment [![](https://i.sstatic.net/fAqX2.jpg?s=64)](https://stackoverflow.com/users/2844859/frozenfrank) Frozenfrank [Frozenfrank](https://stackoverflow.com/users/2844859/frozenfrank) [Over a year ago](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#comment139277890_54469770) I believe this is usually great, but it didn't work on my Mac. Any ideas why it wouldn't work out of the box? 2024-09-16T21:04:56.73Z+00:00 0 Reply - Copy link [![](https://i.sstatic.net/fAqX2.jpg?s=64)](https://stackoverflow.com/users/2844859/frozenfrank) Frozenfrank [Frozenfrank](https://stackoverflow.com/users/2844859/frozenfrank) [Over a year ago](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#comment139277900_54469770) Update: I had tried it in an ssh session to a non-Mac machine. On my actual Mac machine, it works perfectly. 2024-09-16T21:06:19.147Z+00:00 0 Reply - Copy link This answer is useful 44 Save this answer. Show activity on this post. This command copies the content of a file into your clipboard: ``` xclip -selection clipboard -i < file.txt ``` Also, this shorter command copies the content of a file into the mouse middle click: ``` xclip < file.txt ``` [Share](https://stackoverflow.com/a/62737330 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this answer](https://stackoverflow.com/posts/62737330/edit) Follow Follow this answer to receive notifications [edited Nov 24, 2022 at 6:18](https://stackoverflow.com/posts/62737330/revisions "show all edits to this post") [![V. Bozz's user avatar](https://i.sstatic.net/ImtcK.jpg?s=64)](https://stackoverflow.com/users/3451846/v-bozz) [V. Bozz](https://stackoverflow.com/users/3451846/v-bozz) 1,63611 gold badge2323 silver badges4242 bronze badges answered Jul 5, 2020 at 5:51 [![Firoj Siddiki's user avatar](https://i.sstatic.net/pT2ZJ.jpg?s=64)](https://stackoverflow.com/users/10146901/firoj-siddiki) [Firoj Siddiki](https://stackoverflow.com/users/10146901/firoj-siddiki) 1,98911 gold badge2525 silver badges2727 bronze badges ## Comments Add a comment This answer is useful 5 Save this answer. Show activity on this post. If you're copying from terminal (like if you use the cat command already posted), highlight the key details and use `Ctrl` + `Shift` + `C`. This should put it on your clipboard. You can also right click and select 'copy' from terminal. [Share](https://stackoverflow.com/a/41864181 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this answer](https://stackoverflow.com/posts/41864181/edit) Follow Follow this answer to receive notifications [edited Nov 11 at 15:41](https://stackoverflow.com/posts/41864181/revisions "show all edits to this post") [![shA.t's user avatar](https://i.sstatic.net/MBHID.png?s=64)](https://stackoverflow.com/users/4519059/sha-t) [shA.t](https://stackoverflow.com/users/4519059/sha-t) 17\.1k55 gold badges5959 silver badges121121 bronze badges answered Jan 26, 2017 at 0:31 [![e\_m's user avatar](https://i.sstatic.net/B9AH0.jpg?s=64)](https://stackoverflow.com/users/7471693/e-m) [e\_m](https://stackoverflow.com/users/7471693/e-m) 8311 silver badge44 bronze badges ## 1 Comment Add a comment [![](https://www.gravatar.com/avatar/35b5e9e9ccf3bfe5ff8d22b64a5234d3?s=48&d=identicon&r=PG)](https://stackoverflow.com/users/20471/joe-phillips) Joe Phillips [Joe Phillips](https://stackoverflow.com/users/20471/joe-phillips) [Over a year ago](https://stackoverflow.com/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal#comment119741817_41864181) If the file is larger than the screen (for instance when using vim) then this doesn't really work. Only copies the part you have selected 2021-05-28T18:56:04.047Z+00:00 23 Reply - Copy link Start asking to get answers Find the answer to your question by asking. [Ask question](https://stackoverflow.com/questions/ask) Explore related questions - [linux](https://stackoverflow.com/questions/tagged/linux "show questions tagged 'linux'") - [ssh](https://stackoverflow.com/questions/tagged/ssh "show questions tagged 'ssh'") See similar questions with these tags. - The Overflow Blog - [Simulating lousy conversations: Q\&A with Silvio Savarese, Chief Scientist &...](https://stackoverflow.blog/2025/12/11/simulating-lousy-conversations-q-and-a-with-silvio-savarese-chief-scientist-and-head-of-ai-research-at-salesforce/?cb=1 "Simulating lousy conversations: Q&A with Silvio Savarese, Chief Scientist & Head of AI Research at Salesforce") - [Interface is everything, and everything is an interface](https://stackoverflow.blog/2025/12/12/interface-is-everything-and-everything-is-an-interface/?cb=1) - Featured on Meta - [AI Assist is now available on Stack Overflow](https://meta.stackexchange.com/questions/415115/ai-assist-is-now-available-on-stack-overflow?cb=1) - [Native Ads coming soon to Stack Overflow and Stack Exchange](https://meta.stackexchange.com/questions/415259/native-ads-coming-soon-to-stack-overflow-and-stack-exchange?cb=1) - [Policy: Generative AI (e.g., ChatGPT) is banned](https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned?cb=1) Community activity Last 1 hr - Users online activity 18880 users online - 14 questions - 28 answers - 63 comments - 276 upvotes Popular tags [c\#](https://stackoverflow.com/questions/tagged/c)[c](https://stackoverflow.com/questions/tagged/c)[java](https://stackoverflow.com/questions/tagged/java)[c++](https://stackoverflow.com/questions/tagged/c++)[flutter](https://stackoverflow.com/questions/tagged/flutter)[python](https://stackoverflow.com/questions/tagged/python) Popular unanswered question [Using global function with imported namespace](https://stackoverflow.com/questions/68560955) [php](https://stackoverflow.com/questions/tagged/php)[import](https://stackoverflow.com/questions/tagged/import)[syntax](https://stackoverflow.com/questions/tagged/syntax)[namespaces](https://stackoverflow.com/questions/tagged/namespaces)[global](https://stackoverflow.com/questions/tagged/global) [![User avatar](https://lh3.googleusercontent.com/-iqmNCD7c1fA/AAAAAAAAAAI/AAAAAAAAAAA/AAKWJJMDQ9y8IwBhVWACNhNWmGZ_BbMI9Q/s256-rj/photo.jpg)](https://stackoverflow.com/users/14619935) [Tomasz Kardas](https://stackoverflow.com/users/14619935) - 21 1,601 days ago #### Linked [822](https://stackoverflow.com/questions/1620018/copy-all-the-lines-to-clipboard?lq=1 "Question score (upvotes - downvotes)") [Copy all the lines to clipboard](https://stackoverflow.com/questions/1620018/copy-all-the-lines-to-clipboard?noredirect=1&lq=1) #### Related [1913](https://stackoverflow.com/questions/4565700/how-to-specify-the-private-ssh-key-to-use-when-executing-shell-command-on-git?rq=1 "Question score (upvotes - downvotes)") [How to specify the private SSH-key to use when executing shell command on Git?](https://stackoverflow.com/questions/4565700/how-to-specify-the-private-ssh-key-to-use-when-executing-shell-command-on-git?rq=1) [1109](https://stackoverflow.com/questions/9607295/calculate-rsa-key-fingerprint?rq=1 "Question score (upvotes - downvotes)") [Calculate RSA key fingerprint](https://stackoverflow.com/questions/9607295/calculate-rsa-key-fingerprint?rq=1) [1641](https://stackoverflow.com/questions/112396/how-do-i-remove-the-passphrase-for-the-ssh-key-without-having-to-create-a-new-ke?rq=1 "Question score (upvotes - downvotes)") [How do I remove the passphrase for the SSH key without having to create a new key?](https://stackoverflow.com/questions/112396/how-do-i-remove-the-passphrase-for-the-ssh-key-without-having-to-create-a-new-ke?rq=1) [2849](https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux?rq=1 "Question score (upvotes - downvotes)") [How to change the output color of echo in Linux](https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux?rq=1) [1450](https://stackoverflow.com/questions/305035/how-to-use-ssh-to-run-a-local-shell-script-on-a-remote-machine?rq=1 "Question score (upvotes - downvotes)") [How to use SSH to run a local shell script on a remote machine?](https://stackoverflow.com/questions/305035/how-to-use-ssh-to-run-a-local-shell-script-on-a-remote-machine?rq=1) #### [Hot Network Questions](https://stackexchange.com/questions?tab=hot) - [Invertible perturbations of matrices](https://mathoverflow.net/questions/505926/invertible-perturbations-of-matrices) - [Science textbook with a nuclear-powered elephant](https://scifi.stackexchange.com/questions/302463/science-textbook-with-a-nuclear-powered-elephant) - [What is proper knife technique for patching wall holes and cracks in one application?](https://diy.stackexchange.com/questions/328027/what-is-proper-knife-technique-for-patching-wall-holes-and-cracks-in-one-applica) - [Graphing the function y=x^2sin(1/x)](https://tex.stackexchange.com/questions/757104/graphing-the-function-y-x2sin1-x) - [Is it possible to measure scalar potential difference with a voltmeter/oscilloscope?](https://physics.stackexchange.com/questions/866617/is-it-possible-to-measure-scalar-potential-difference-with-a-voltmeter-oscillosc) - [Feasibility of a thermite-based “Lava bomb”](https://worldbuilding.stackexchange.com/questions/271033/feasibility-of-a-thermite-based-lava-bomb) - [LeetCode 2. Add Two Numbers](https://codereview.stackexchange.com/questions/299744/leetcode-2-add-two-numbers) - [Renaming video files from a wordlist across multiple directories](https://codereview.stackexchange.com/questions/300750/renaming-video-files-from-a-wordlist-across-multiple-directories) - [Why do \_llseek and ftruncate64 have their argument order reversed from each other in Linux i386 syscall ABI?](https://retrocomputing.stackexchange.com/questions/32332/why-do-llseek-and-ftruncate64-have-their-argument-order-reversed-from-each-othe) - [A SF short story about a detective with an original method to identify a drug trafficker](https://scifi.stackexchange.com/questions/302459/a-sf-short-story-about-a-detective-with-an-original-method-to-identify-a-drug-tr) - [Does it take longer to melt one big piece of ice or many small pieces of ice?](https://physics.stackexchange.com/questions/866666/does-it-take-longer-to-melt-one-big-piece-of-ice-or-many-small-pieces-of-ice) - [How can materialist philosophers reconcile between freewill and determinism aka adopting compatibilism?](https://philosophy.stackexchange.com/questions/134462/how-can-materialist-philosophers-reconcile-between-freewill-and-determinism-aka) - [Huffman compressor/decompressor in C17](https://codereview.stackexchange.com/questions/300743/huffman-compressor-decompressor-in-c17) - [How should moral responsibility be understood in relation to early upbringing, environment, and religious concepts such as destiny?](https://philosophy.stackexchange.com/questions/134429/how-should-moral-responsibility-be-understood-in-relation-to-early-upbringing-e) - [Is it possible to create LLM using NEAT or its variations?](https://ai.stackexchange.com/questions/50179/is-it-possible-to-create-llm-using-neat-or-its-variations) - [Why do plane engines require substantial ground clearance?](https://aviation.stackexchange.com/questions/114738/why-do-plane-engines-require-substantial-ground-clearance) - [Fillet Curve with Per-Corner Radii for selected index](https://blender.stackexchange.com/questions/343953/fillet-curve-with-per-corner-radii-for-selected-index) - [A problem about random permutations](https://math.stackexchange.com/questions/5114932/a-problem-about-random-permutations) - [Is the 'sibling rivalry' effect balanced for the rarity?](https://rpg.stackexchange.com/questions/218287/is-the-sibling-rivalry-effect-balanced-for-the-rarity) - [Is there something similar to Struik’s book for the period after 1800?](https://hsm.stackexchange.com/questions/19081/is-there-something-similar-to-struik-s-book-for-the-period-after-1800) - [How to prevent screw from working its way out in wood furniture](https://diy.stackexchange.com/questions/328016/how-to-prevent-screw-from-working-its-way-out-in-wood-furniture) - [Odd cycle through a given edge](https://cs.stackexchange.com/questions/175936/odd-cycle-through-a-given-edge) - [Is the 'L' in 'Chalk' actually silent?](https://english.stackexchange.com/questions/638226/is-the-l-in-chalk-actually-silent) - [In Windows 11 firewall default setting, why are there two identical rules for ICMP, and what does (restrictive) in rule names mean?](https://superuser.com/questions/1932444/in-windows-11-firewall-default-setting-why-are-there-two-identical-rules-for-ic) ![](https://stackoverflow.com/posts/32039476/ivc/7e97?prg=410af534-3a73-4bc7-845c-75cedc446092) # Why are you flagging this comment? Probable spam. This comment promotes a product, service or website while [failing to disclose the author's affiliation](https://stackoverflow.com/help/promotion). Unfriendly or contains harassment/bigotry/abuse. This comment is unkind, insulting or attacks another person or group. Learn more in our [Abusive behavior policy](https://stackoverflow.com/conduct/abusive-behavior). Not needed. This comment is not relevant to the post. ``` ``` Enter at least 6 characters Something else. A problem not listed above. Try to be as specific as possible. ``` ``` Enter at least 6 characters Flag comment Cancel You have 0 flags left today # ![Illustration of upvote icon after it is clicked](https://stackoverflow.com/Content/Img/modal/img-upvote.png?v=fce73bd9724d) # Hang on, you can't upvote just yet. You'll need to complete a few actions and gain 15 reputation points before being able to upvote. **Upvoting** indicates when questions and answers are useful. [What's reputation and how do I get it?](https://stackoverflow.com/help/whats-reputation) Instead, you can save this post to reference later. Save this post for later Not now ##### [Stack Overflow](https://stackoverflow.com/) - [Questions](https://stackoverflow.com/questions) - [Help](https://stackoverflow.com/help) - [Chat](https://chat.stackoverflow.com/?tab=explore) ##### [Business](https://stackoverflow.co/) - [Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams) - [Stack Data Licensing](https://stackoverflow.co/data-licensing/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=data-licensing) - [Stack Ads](https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising) ##### [Company](https://stackoverflow.co/) - [About](https://stackoverflow.co/) - [Press](https://stackoverflow.co/company/press/) - [Work Here](https://stackoverflow.co/company/work-here/) - [Legal](https://stackoverflow.com/legal) - [Privacy Policy](https://stackoverflow.com/legal/privacy-policy) - [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public) - [Contact Us](https://stackoverflow.com/contact) - Cookie Settings - [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy) ##### [Stack Exchange Network](https://stackexchange.com/) - [Technology](https://stackexchange.com/sites#technology) - [Culture & recreation](https://stackexchange.com/sites#culturerecreation) - [Life & arts](https://stackexchange.com/sites#lifearts) - [Science](https://stackexchange.com/sites#science) - [Professional](https://stackexchange.com/sites#professional) - [Business](https://stackexchange.com/sites#business) - [API](https://api.stackexchange.com/) - [Data](https://data.stackexchange.com/) - [Blog](https://stackoverflow.blog/?blb=1) - [Facebook](https://www.facebook.com/officialstackoverflow/) - [Twitter](https://twitter.com/stackoverflow) - [LinkedIn](https://linkedin.com/company/stack-overflow) - [Instagram](https://www.instagram.com/thestackoverflow) Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2025.12.15.38053
Readable Markdownnull
Shard169 (laksa)
Root Hash714406497480128969
Unparsed URLcom,stackoverflow!/questions/32039476/copy-file-contents-to-the-clipboard-in-linux-terminal s443