In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
What are the pbcopy and pbpaste commands in the Linux system? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Pbcopy: the main function of the command is to copy the information to the clipboard. In the figure above, the path shown by pwd is copied to the clipboard; the main function of pbpaste is to paste the contents of the clipboard to the current environment. The pbpaste in the picture above represents the contents of the clipboard. Here is a detailed explanation of the use of the pbcopy and pbpaste commands.
Install xclip / xsel as I have said, there are no pbcopy and pbpaste commands in Linux. However, we can use the xclip and / or xsel commands to copy the functionality of the pbcopy and pbpaste commands through the shell alias. The xclip and xsel packages exist in the default repository for most Linux distributions. Please note that you do not need to install these two programs. You only need to install any of the above programs.
To install them on Arch Linux and its derivative production, run:
$sudo pacman xclip xsel on Fedora:
$sudo dnf xclip xsel on Debian, Ubuntu, Linux Mint:
After sudo apt install xclip xsel is installed, you need to create aliases for the pbcopy and pbpaste commands. To do this, edit ~ / .bashrc:
$vi ~ / .bashrc if you want to use xclip, paste the following line:
Alias pbcopy='xclip-selection clipboard' alias pbpaste='xclip-selection clipboard-o' if you want to use xsel, paste the following line in ~ / .bashrc.
Alias pbcopy='xsel-clipboard-input' alias pbpaste='xsel-clipboard-output' saves and closes the file.
Next, run the following command to update the changes in ~ / .bashrc.
$source ~ / .bashrcZSH users paste the above lines into ~ / .zshrc.
Using the pbcopy and pbpaste commands on Linux shows us some examples.
The pbcopy command copies the text from the stdin to the clipboard buffer. For example, look at the following example.
$echo "Welcome To OSTechNix!" | the command above pbcopy copies the text "Welcome to OSTechNix" to the clipboard. You can access this content later and paste it anywhere using the pbpaste command shown below.
$echo `pbpaste` Welcome To OSTechNix!
Here are some other examples.
I have a file called file.txt that contains the following.
$cat file.txt Welcome To OSTechNix! You can copy the contents of the file directly to the clipboard, as shown below.
Pbcopy now, as long as you update the clipboard with the contents of other files, then the contents of the clipboard are available. To retrieve content from the clipboard, simply type: $pbpaste Welcome To OSTechNix! You can also use pipe characters to send the output of any Linux command to the clipboard. Look at the following example. $ps aux | pbcopy now enter the pbpaste command to display the output of the ps aux command in the clipboard. Pbpaste can do more with the pbcopy and pbpaste commands. I hope you have a basic idea of these commands now. At this point, the sharing of pbcopy and pbpaste command tutorials on Linux system is over. you are welcome to leave a message in the comments area. The above is the Linux system-related content shared by Liangxu tutorial Network for all friends. If you want to know more about Linux, remember to follow the official account "good Linux", or scan the QR code below to follow, more practical information is waiting for you! After reading the above, have you mastered what the pbcopy and pbpaste commands are in the Linux system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.