commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Using column to format a directory listing
This will comment out a line, specified by line number, in a given file.
Searches for all .project files in current folder and below and uses "svn info" to get the last changed revision. The last sed joins every two lines.
Filters out all non-insert SQL operations (we couldn't filter out only lines starting with "INSERT" because inserts can span multiple lines), quotes table names with backticks, saves dump to a file and pipes it straight to mysql.
This transfers only data--it expects your schema is already in place. In Ruby on Rails, you can easily recreate the schema in MySQL with "rake db:schema:load RAILS_ENV=production".
I needed a way to search all files in a web directory that contained a certain string, and replace that string with another string. In the example, I am searching for "askapache" and replacing that string with "htaccess". I wanted this to happen as a cron job, and it was important that this happened as fast as possible while at the same time not hogging the CPU since the machine is a server.
So this script uses the nice command to run the sh shell with the command, which makes the whole thing run with priority 19, meaning it won't hog CPU processing. And the -P5 option to the xargs command means it will run 5 separate grep and sed processes simultaneously, so this is much much faster than running a single grep or sed. You may want to do -P0 which is unlimited if you aren't worried about too many processes or if you don't have to deal with process killers in the bg.
Also, the -m1 command to grep means stop grepping this file for matches after the first match, which also saves time.
Convert string to array using echo and sed =)
this string of commands will release your dhcp address, change your mac address, generate a new random hostname and then get a new dhcp lease.
Download the last show on your TiVo DVR.
Replace $MAK with your MAK see https://www3.tivo.com/tivo-mma/showmakey.do
Replace $tivo with your TiVo's IP
No need to loop when we have `xargs`. The sed command filters out the first line of `show databases` output, which is always "Database".
"get Hong Kong weather infomation from HK Observatory
From Hong Kong Observatory wap site ;)"
other one showed alot of blank lines for me
From Hong Kong Observatory wap site ;)
Uses curl to download page of membership of US Congress. Use sed to strip HTML then perl to print a line starting with two tabs (a line with a representative)
You're behind on your TV catch-up, but how far behind? This command tries to open mplayer against all files in the current dir. If it's a video file it will contain ID_LENGTH, which is summed and output in hours, minutes and seconds.
Someone better at awk could probably reduce this down a lot.
List all text files in the current directory.
Assuming that $script contains the filename of a script you'd like to post as part of a comment on this site, this will prefix each line with '$' and pipe it into the X selection. From there just put the cursor in the right place in the comments box and middle-click.
Should work pretty much anywhere with xclip installed. On debian-ish systems this is installed as part of the package "xclip".
search argument in PATH
accept grep expressions
without args, list all binaries found in PATH