ls | curl -F 'sprunge=<-' http://sprunge.us | xclip

Run a command, store the output in a pastebin on the internet and place the URL on the xclipboard

The URL can then be pasted with a middle click. This is probably useful when trying to explain problems over instant messaging when you don't have some sort of shared desktop.

16
By: tatwright
2009-06-06 11:35:14
ls

These Might Interest You

  • paste file to pastebin (other similar sites available, read man page). make sure to have 'pastebinit' install


    -12
    pastebinit [file]
    Bonster · 2011-12-22 14:21:47 0
  • echo "Hello world!" | sprunge # Redirect a stream to a pastebin sprunge ~/.bashrc # Send a file to a pastebin


    1
    sprunge() { curl -F 'sprunge=<-' http://sprunge.us < "${1:-/dev/stdin}"; }
    malathion · 2014-08-26 17:47:31 0
  • Some commands (such as sed and perl) have options to support in-place editing of files, but many commands do not. This shell function enables any command to change files in place. See the sample output for many examples. The function uses plain sh syntax and works with any POSIX shell or derivative, including zsh and bash. Show Sample Output


    1
    inplace() { eval F=\"\$$#\"; "$@" > "$F".new && mv -f "$F".new "$F"; }
    inof · 2010-04-09 11:36:31 8
  • Place it in your bashrc and running the command radio it will turn on or off each time it runs. Only one command needed. Obviously you can set it to any station you like.


    0
    radio() { if [ "$(pidof mpg123)" ] ; then killall mpg123; else mpg123 -q -@ http://173.236.29.51:8200 & fi }
    houghi · 2010-11-14 16:27:04 0
  • This command is useful if you want to copy the output of a series of commands to a file, for example if you want to pastebin the output from 'uname -a', 'lspci -vvv' and 'lsmod' for video driver trouble-shooting on your favorite Linux forum. 'log' takes all the following arguments as a command to execute, with STDOUT sent to /var/log/user.log. The command is echoed to the log before it is executed. The advantages of using logger (as opposed to appending output from commands to a file) are 1) commands are always appended to the logs... you don't have to worry about clobbering your log file accidentally by using '>' rather than '>>' 2) logs are automatically cleaned up by logrotate. The following functions allow you to mark the start and end of a section of /var/log/user.log. startlog() { export LOGMARK=$(date +%Y.%m.%d_%H:%M:%S); echo "$LOGMARK.START" | logger -t $USER; } then endlog() { echo "$LOGMARK.END" | logger -t $USER; } printlog will print all lines between $LOGMARK.START and $LOGMARK.END, removing everything that is prepended to each line by logger. printlog() { sudo sed -n -e "/$LOGMARK.START/,/$LOGMARK.END/p" /var/log/user.log| sed "s/.*$USER: //"; } The following command should dump just about all the information that you could possibly want about your linux configuration into the clipboard. startlog; for cmd in 'uname -a' 'cat /etc/issue' 'dmesg' 'lsusb' 'lspci' 'sudo lshw' 'lsmod'; do log $cmd; done; endlog; printlog | xsel --clipboard This is ready for a trip to http://pastebin.com/, and you don't have to worry about leaving temporary files lying around cluttering up $HOME. Caveats: I'm sure that startlog, endlog, and printlog could use some cleanup and error checking... there are unchecked dependencies between printlog and endlog, as well as between endlog and startlog. It might be useful for 'log' to send stderr to logger as well. Show Sample Output


    4
    log() { (echo "\$ $@";$@) | logger -t $USER; }
    bartonski · 2010-09-25 20:43:22 0
  • Can be used to discover what programms create internet traffic. Skip the part after awk to get more details. Has anyone an idea why the uniq doesn't work propperly here (see sample output)? Show Sample Output


    -1
    netstat -lantp | grep -i establ | awk -F/ '{print $2}' | uniq | sort
    ktoso · 2009-09-19 13:54:36 3

What Others Think

With xsel instead of xclip: ls | curl -F 'sprunge=<-' http://sprunge.us | xsel -b -i
Weboide · 466 weeks and 5 days ago
or for OSX, using pbcopy: ls | curl -F 'sprunge=<' http://sprunge.us | pbcopy
zzamboni · 466 weeks and 4 days ago
I use a script for that using the main pastebin.com. You can see/test it : sputnick-area.net/ftp/downloads/pastebin-grabber-EN.bash ./pastebin-grabber-EN.bash -h Usage : pastebin-grabber-EN.bash -i pastebin-grabber-EN.bash [[-ceth] ] Options : -i = interactive mode You have to type the content ( "/path/to/file" or "-" for STDIN ) With "-", you can paste your clipboard. and optionally, the type of content. Default is "text" Example : "#? /tmp/test.bash bash" -c = content to upload ( file or string ) -e = expiration ( d=day, m=month, f=forever ) -t = type of content ( bash, text, perl, html, php...) -h = help Usage example : bash pastebin-grabber-EN.bash -i bash pastebin-grabber-EN.bash Description : pastebin-grabber-EN.bash is a tool to upload stuff on pastebin.com. The script display the url at the end and put it in the buffer. Next step for you is to give this URL for who needs.
sputnick · 466 weeks and 3 days ago
to sputnick: share your script at some pastebin service please, I can't get it by link you gave - it says "Error 404"...
Minoru · 466 weeks and 1 day ago
If you're using XChat and want to support others, ask them to type this command within XChat's window: /exec -o ls | curl -sF 'sprunge=<-' sprunge.us The change is the addition of -s which means silent mode, so all you'll get from the other person is the direct link to the output of the command you ask them to run. Can't get any simpler than this!
d3Xt3r · 344 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: