Commands by stu (2)

  • apart from not being generalisable to all shells, `Y <<< X` seems nicer to me than `echo X | Y`, e.g. &lt;&lt;&lt; lol cat; it reads easier, you type less, and it also looks cool

    base64 -d <<< aHR0cDovL3d3dy50d2l0dGVyc2hlZXAuY29tL3Jlc3VsdHMucGhwP3U9Y29tbWFuZGxpbmVmdQo=
    stu · 2009-03-27 23:20:23 5
  • this exits bash without saving the history. unlike explicitly disabling the history in some way, this works anywhere, and it works if you decide *after* issuing the command you don't want logged, that you don't want it logged ... $$ ( or ${$} ) is the pid of the current bash instance this also works perfectly in shells that don't have $$ if you do something like kill -9 `readlink /proc/self`

    kill -9 $$
    stu · 2009-03-27 23:13:53 4

What's this? 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

Find wich ports you probably want to open in your firewall on a fresh installed machine

Convert encoding from cp1252 (MS Windows) to UTF-8 on source code files

Capture data in ASCII. 1500 bytes
Sniffing traffic on port 80 only the first 1500 bytes

convert wav files to ogg
cd to the folder containing the wav files and convert them all to ogg format. in my sample output i use the -a and -l flags to set the author and album title. to get the oggenc program in ubuntu linux run: sudo apt-get install oggenc

convert a,b,c to ('a','b','c') for use in SQL in-clauses

Quickly create an alias for changing into the current directory
Put the function in your .bashrc and use "map [alias]" to create the alias you want. Just be careful to not override an existing alias.

Use tagged vlans
Great for sysadmins! Don't forget to pass the vlan to your port in a manageable switch. After vconfig, you should use $sudo ifconfig eth0.[VID] up Now the interface is up, you can use dhclient or ifconfig again to get an ip address.

add the result of a command into vi
':r!ls -l' results in listing the files in the current directory and paste it into vi

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Limit memory usage per script/program
When I'm testing some scripts or programs, they end up using more memory than anticipated. In that case, computer nearly halts due to swap space usage, and sometimes I have to press Magic SysRq+REISUB to reboot. So, I was looking for a way to limit memory usage per script and found out that ulimit can limit memory. If you run it this way: $ $ ulimit -v 1000000 . $ $ scriptname Then the new memory limit will be valid for that shell. I think changing the limit within a subshell is much more flexible and it won't interfere with your current shell ulimit settings. note: -v 1000000 corresponds to approximately 1GB of RAM

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.


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: