Shell Script useful bits and pieces (share thread)

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
Fhenrir

Shell Script useful bits and pieces (share thread)

Post by Fhenrir »

Perhaps it might be worth to have a thread to share shell stuff (bash) and bits of code useful for scripts or bashrc.

To start, a line I use in bashrc to send the output of commands to a pastebin.

Code: Select all

sprunge(){ ${@} | curl -s -F 'sprunge=<-' http://sprunge.us | sed ' a ?bash ' | paste -d '' - - ; }
Usage: sprunge <commands> ## for arguments with pipes or long commands: sprunge $(<commands>)
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29612
Joined: Wed Jul 06, 2011 3:58 am

Re: Shell Script useful bits and pieces (share thread)

Post by xenopeek »

(There is a command pastebin on Linux Mint; you can just pipe output of any command to that to send it to the Linux Mint pastebin server and get a URL back...)
Image
Fhenrir

Re: Shell Script useful bits and pieces (share thread)

Post by Fhenrir »

That's good to know. It's seems easier to use the pastebin command as you only pipe the output. But for general use (not distro specific) it could be useful.
DrHu

Re: Shell Script useful bits and pieces (share thread)

Post by DrHu »

https://nicolamonaca.wordpress.com/2015 ... -snippets/
http://www.shellperson.net/sprunge-pastebin-script/
--quick check of that command..

http://www.shellperson.net/tag/bash/
--that person may be useful, and I guess there are others on the internet just as valuable..
  • Its for all, going to be just a matter of digging in and practising
Also curl is very useful
http://www.thegeekstuff.com/2012/04/curl-examples/
Fhenrir

Re: Shell Script useful bits and pieces (share thread)

Post by Fhenrir »

Great links!

I have this one in bashrc to search in commandlinefu.com

Code: Select all

cmdfu(){ wget -q -O - "http://www.commandlinefu.com/commands/matching/$@/$(echo -n "$@" | openssl base64)/plaintext" ; } 
Usage: cmdfu "<word1> <word2>"
UltramaticOrange

Re: Shell Script useful bits and pieces (share thread)

Post by UltramaticOrange »

Code: Select all

ssh user@10.10.10.10 -D 8080 -NfgC
where 10.10.10.10 is the IP of some remote host on a network that you trust.

This spins up a SOCKS5 proxy on port 8080 that anyone on the local network can point their browsers at. Remove the '-g' switch if you only want localhost to connect to it. A good idea on public networks or if you have to hop onto a network you don't trust.
Locked

Return to “Scripts & Bash”