In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to easily upload text fragments to Pastebin-like services from the command line. I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it.
Whenever we need to share code snippets online, the first thing we think of is Pastebin.com, an online text-sharing site launched by Paul Dixon in 2002. There are now several text sharing services to choose from to upload and share text snippets, error logs, configuration files, command output, or any type of text file. If you happen to often use a variety of Pastebin-like services to share code, this is really good news for you. Say hello to Wgetpaste, a command-line BASH utility that easily uploads text summaries to Pastebin-like services. Using Wgetpaste scripts, anyone can quickly share text snippets with their friends, colleagues, or people who want to view / use / review code on the command line on a Unix-like system.
Install Wgetpaste
Wgetpaste is available in the Arch Linux [Community] repository. To install it on Arch Linux and its variants, such as Antergos and Manjaro Linux, simply run the following command:
$sudo pacman-S wgetpaste
For other distributions, obtain the source code from the Wgetpaste website and install it manually as described below.
First download the latest Wgetpaste tar file:
$wget http://wgetpaste.zlin.dk/wgetpaste-2.28.tar.bz2
Extract it:
$tar-xvjf wgetpaste-2.28.tar.bz2
It extracts the contents of the tar file into a folder called wgetpaste-2.28.
Go to this directory:
$cd wgetpaste-2.28/
Copy the wgetpaste binary into $PATH, for example, / usr/local/bin/.
$sudo cp wgetpaste / usr/local/bin/
Finally, use the command to make it executable:
$sudo chmod + x / usr/local/bin/wgetpaste uploads text snippets to a service like Pastebin
Uploading text snippets using Wgetpaste is easy. Let me show you some examples.
1. Upload text files
To upload any text file using Wgetpaste, simply run:
$wgetpaste mytext.txt
This command will upload the contents of the mytext.txt file.
Sample output:
Your paste can be seen here: https://paste.pound-python.org/show/eO0aQjTgExP0wT5uWyX7/
You can share pastebin's URL via email, SMS, whatsapp or IRC. Anyone who owns this URL can access it and view the contents of the text file in the Web browser of their choice.
This is the contents of the mytext.txt file in the Web browser:
You can also use the tee command to display pasted content instead of blindly uploading them.
To do this, use the-t option below.
$wgetpaste-t mytext.txt
2. Upload text clips to other services
By default, Wgetpaste uploads text snippets to the poundpython (https://paste.pound-python.org/) service.
To view a list of supported services, run:
$wgetpaste-S
Sample output:
Services supported: (case sensitive): Name: | Url:= | = bpaste | https://bpaste.net/codepad | http://codepad.org/dpaste | http://dpaste.com/gists | https://api.github.com/gists*poundpython | https://paste.pound-python.org/
Here, * represents the default service.
As you can see, Wgetpaste currently supports five text sharing services. I haven't tried all of them, but I believe all services can be used.
To upload content to another service, such as bpaste.net, use the-s option shown below.
$wgetpaste-s bpaste mytext.txtYour paste can be seen here: https://bpaste.net/show/5199e127e7333, read input from standard input
Wgetpaste can also be read from standard input.
$uname-a | wgetpaste
This command will upload the output of the uname-a command.
4. Upload command and output of command
Sometimes, you may need to paste the command and its output. To do this, specify the contents of the command in quotation marks as shown below.
$wgetpaste-c'ls-l'
This uploads the command ls-l and its output to the pastebin service.
This feature is useful when you want others to know exactly what command you just ran and its output.
As you can see in the output, I ran the ls-l command.
5. Upload system log files and configuration files
As I have said, we can upload any type of text file on your system, not just ordinary text files, such as log files, output of specific commands, and so on. For example, you just updated the Arch Linux machine, and finally the system was damaged. You ask your colleague how to solve this problem, and he or she wants to read the pacman.log file. This is the command to upload the contents of the pacman.log file:
$wgetpaste / var/log/pacman.log
Share pastebin URL with your colleague so that he or she can view the pacman.log and help you solve the problem by looking at the log file.
In general, the contents of log files may be too long and you don't want to share them all. In this case, simply use the cat command to read the output, then use the tail-n command to define the number of lines to share, and finally pipe the output to Wgetpaste, as shown below.
$cat / var/log/pacman.log | tail-n 50 | wgetpaste
The above command will upload only the "last 50 lines" of the pacman.log file.
6. Convert the input URL to a short link
By default, Wgetpaste displays the full pastebin URL in the output. If you want to convert input URL to short links, simply use the-u option.
$wgetpaste-u mytext.txtYour paste can be seen here: http://tinyurl.com/y85d8gtz7, setting language
By default, Wgetpaste uploads text snippets from "plain text".
To list the languages supported by the specified service, use the-L option.
$wgetpaste-L
This command lists all languages supported by the default service (poundpython https://paste.pound-python.org/).
We can use the-l option to change it.
$wgetpaste-l Bash mytext.txt8, disable syntax highlighting in output, or html
As mentioned above, text snippets will be displayed in a specific language format (plain text, Bash, and so on).
However, you can change this behavior to display a summary of the original text using the-r option.
$wgetpaste-r mytext.txtYour raw paste can be seen here: https://paste.pound-python.org/raw/CUJhQ3jEmr2UvfmD2xCL/
As you can see in the output above, there is no syntax highlighting, no html format. It's just the original output.
9. Change the Wgetpaste default value
All default values (DEFAULT_ {NICK,LANGUAGE,EXPIRATION} [_ ${SERVICE}] and DEFAULT_SERVICE) can be changed globally in / etc/wgetpaste.conf or on a per-user basis in the ~ / .wgetpaste.conf file. However, these files do not exist by default on my system. I think we need to create them manually. Developers have provided sample content for these two files here and here. Simply create these files manually with the given sample contents and modify the parameters accordingly to change the default settings for Wgetpaste.
10. Get help
To display the help section, run:
The above $wgetpaste-h is all about the article "how to easily upload text snippets to Pastebin-like services from the command line". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.