Commands by shanford (2)

  • We had a number of git tags named similarly to: 2016.12.13.devel.feature 2016.12.14.master.release But we have multiple developers making commits and tags for testing purposes. I wanted to reduce the number of tags that displayed on our cloud hosting server when doing a deployment.


    0
    git ls-remote --tags origin | awk '/^(.*)(\s+)(.*)(YOUR-TAG-SPECIFIC-SEARCH-TERM-HERE)(.*)(-+)(.*)[^{}]$/ {print ":" $2}' | xargs git push origin
    shanford · 2017-03-06 21:59:15 20
  • I was looking for an easy solution where I could list all of the directories that had a specific file, not to replace it, but more of providing a list to a third-party or for my own reference. Show Sample Output


    0
    find $(pwd) | grep README.txt
    shanford · 2015-01-16 16:58:04 8

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


Check These Out

Get number of users on a minecraft server
I'm flat-out surprised that minecraft directory services require servers install multiple modifications to their server code, when the directories could fetch this information on their own.

Generate soothing noise
Substitute 'brown' with 'pink' or 'white' according to your taste. I put this on my headphones when I'm working in an "open concept" office, where there are always three to five conversations going in earshot, or if I'm working somewhere it is "rude" of me to tell a person to turn off their cubicle radio.

play audio stream and video stream in two different mplayer instances
Sometimes audio and video are not sync'ed. The factor 1.0884 is the quotient 48000/44100. One mplayer plays the audio file in the background, the other the video in the foreground. You can dump the audio file before with another commandlinefu

Make vim open in tabs by default (save to .profile)
I always add this to my .profile rc so I can do things like: "vim *.c" and the files are opened in tabs.

Port Knocking!
Knock on ports to open a port to a service (ssh for example) and knock again to close the port. You have to install knockd. See example config file below. [options] logfile = /var/log/knockd.log [openSSH] sequence = 3000,4000,5000 seq_timeout = 5 command = /sbin/iptables -A INPUT -i eth0 -s %IP% -p tcp --dport 22 -j ACCEPT tcpflags = syn [closeSSH] sequence = 5000,4000,3000 seq_timeout = 5 command = /sbin/iptables -D INPUT -i eth0 -s %IP% -p tcp --dport 22 -j ACCEPT tcpflags = syn

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Installing debian on fedora (chrooted)

Complex string encoding with sed
Pipe | avoid escaping occurences problems in using sed and make it easier to use

send tweets to twitter (and get user details)
great for outputting tweets from cron jobs and batch scripts

check open ports without netstat or lsof


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: