Usage:
translate <phrase> <source-language> <output-language>
Example:
translate hello en es
See this for a list of language codes:
http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
hola
Prints a graphical directory tree from your current directory
|-Comics |---Anomaly |---Cyanide & Happiness |---Dilbert |---Misc |---Pearls Before Swine |---Russell's Teapot |---xkcd |-Docks |---Niqu Dock 1.2 |-----2D Style |-----3D Style |-----Defaults |---Rounded Reflection |-Ebooks |---The Guitarist's Guide to Composing and Improvising
This is the result of a several week venture without X. I found myself totally happy without X (and by extension without flash) and was able to do just about anything but watch YouTube videos... so this a the solution I came up with for that. I am sure this can be done better but this does indeed work... and tends to work far better than YouTube's ghetto proprietary flash player ;-) Replace $i with any YouTube ID you want and this will scrape the site for the _real_ URL to the full quality .FLV file on Youtube's server and will then will hand that over to mplayer (or vlc or whatever you want) to be streamed. In some browsers you can replace $i with just a % or put this in a shell script so all YouTube IDs can be handed directly off to your media player of choice for true streaming without the need for Flash or a downloader like clive. (I do however fully recommend clive if you wish to archive videos instead of streaming them) If any interest is shown I would be more than happy to provide similar commands for other sites. Most streaming flash players use similar logic to YouTube. Edit: 05/03/2011 - Updated line to work with current YouTube. It could be a lot prettier but I will probably follow up with another update when I figure out how to get rid of that pesky Grep. Sed should take that syntax... but it doesn't. Original (no longer working) command: mplayer -fs $(echo "http://youtube.com/get_video.php?$(curl -s $youtube_url | sed -n "/watch_fullscreen/s;.*\(video_id.\+\)&title.*;1円;p")")
MPlayer SVN-r32999-4.4.5 (C) 2000-2011 MPlayer Team Playing http://v3.lscache2.c.youtube.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor&fexp=901031%2C907508%2C900304&algorithm=throttle-factor&itag=34&ipbits=8&burst=40&sver=3&signature=97D6F8D1A948EF2451FD4F093ECA7EF3795EE424.73F2B07D5F478ACEAFCEAC98E7BF2623FEED20EC&expire=1299384000&key=yt1&ip=97.0.0.0&factor=1.25&id=f2ecb156675a27ec. Resolving v3.lscache2.c.youtube.com for AF_INET6... Couldn't resolve name for AF_INET6: v3.lscache2.c.youtube.com Resolving v3.lscache2.c.youtube.com for AF_INET... Connecting to server v3.lscache2.c.youtube.com[74.125.15.14]: 80... Cache size set to 320 KBytes Cache fill: 19.54% (64036 bytes) libavformat file format detected. [flv @ 0x2acf540] Estimating duration from bitrate, this may be inaccurate [lavf] stream 0: video (h264), -vid 0 [lavf] stream 1: audio (aac), -aid 0 VIDEO: [H264] 640x360 0bpp 24.000 fps 557.2 kbps (68.0 kbyte/s) Clip info: duration: 162 starttime: 0 totalduration: 162 width: 640 height: 360 videodatarate: 544 audiodatarate: 97 totaldatarate: 649 framerate: 24 bytelength: 13120260 canseekontime: true sourcedata: B4A7D0F03HH1299359484777471 purl: pmsg: ========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264) ========================================================================== ========================================================================== Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders AUDIO: 44100 Hz, 2 ch, s16le, 99.0 kbit/7.02% (ratio: 12379->176400) Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio)) ========================================================================== [AO OSS] audio_setup: Can't open audio device /dev/dsp: Device or resource busy AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample) Starting playback... Movie-Aspect is 1.78:1 - prescaling to correct movie aspect. VO: [xv] 640x360 => 640x360 Planar YV12 [fs] A: 2.4 V: 2.4 A-V: -0.000 ct: 0.000 0/ 0 19% 15% 0.4% 7 0 47%
Checks the Gmail ATOM feed for your account, parses it and outputs a list of unread messages.
For some reason sed gets stuck on OS X, so here's a Perl version for the Mac:
curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*<name>(.*)<\/name>.*$/2ドル - 1ドル/'
If you want to see the name of the last person, who added a message to the conversation, change the greediness of the operators like this:
curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*?<name>(.*?)<\/name>.*$/2ドル - 1ドル/'
Contact Name - Email Subject Contact Name2 - Email Subject2 (...)
You can get one specific line during any procedure. Very interesting to be used when you know what line you want.
jeju:[xxx] > sed -n 5p test line 5 jeju:[xxx] > cat test line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 line 9 line 10 jeju:[xxx] >
Nothing special required, just wget, sed & tr!
Resolving v3.lscache3.c.youtube.com... 74.125.170.46 Connecting to v3.lscache3.c.youtube.com|74.125.170.46|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 25120289 (24M) [video/x-flv] Saving to: `surprise.flv'
(relies on 'imagemagick') This command will convert all .pdf files in a directory into a 800px (wide or height, whichever is smaller) image (with the aspect ratio kept) .jpg. If the file is named 'example1.pdf' it will be named 'example1.jpg' when it is complete. This is a VERY worthwhile command! People pay hundreds of dollars for this in the Windows world. My .jpg files average between 150kB to 300kB, but your's may differ.
for file in `ls *.pdf`; do convert -verbose -colorspace RGB -resize 800 -interlace none -density 300 -quality 80 $file `echo $file | sed 's/\.pdf$/\.jpg/'`; done "gs" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" "-sOutputFile=/tmp/magick-XXz6cMMo" "-f/tmp/magick-XX9DNL7g" "-f/tmp/magick-XXPGU3s9"
Sed stops parsing at the match and so is much more effecient than piping head into tail or similar. Grab a line range using
sed '999995,1000005!d' < my_massive_file
recursively traverse the directory structure from . down, look for string "oldstring" in all files, and replace it with "newstring", wherever found
also:
grep -rl oldstring . |xargs perl -pi~ -e 's/oldstring/newstring'
If you have used bash for any scripting, you've used the date command alot. It's perfect for using as a way to create filename's dynamically within aliases,functions, and commands like below.. This is actually an update to my first alias, since a few commenters (below) had good observations on what was wrong with my first command.
# creating a date-based ssh-key for askapache.github.com
ssh-keygen -f ~/.ssh/`date +git-$USER@$HOSTNAME-%m-%d-%g` -C 'webmaster@askapache.com'
# /home/gpl/.ssh/git-gplnet@askapache.github.com-04-22-10
# create a tar+gzip backup of the current directory
tar -czf $(date +$HOME/.backups/%m-%d-%g-%R-`sed -u 's/\//#/g' <<< $PWD`.tgz) .
# tar -czf /home/gpl/.backups/04-22-10-01:13-#home#gpl#.rr#src.tgz .
I personally find myself having to reference
date --help
quite a bit as a result. So this nice alias saves me a lot of time. This is one bdash mofo. Works in sh and bash (posix), but will likely need to be changed for other shells due to the parameter substitution going on.. Just extend the sed command, I prefer sed to pretty much everything anyways.. but it's always preferable to put in the extra effort to go for as much builtin use as you can. Otherwise it's not a top one-liner, it's a lazyboy recliner.
Here's the old version:
alias dateh='date --help|sed "/^ *%%/,/^ *%Z/!d;s/ \+/ /g"|while read l;do date "+ %${l/% */}_${l/% */}_${l#* }";done|column -s_ -t'
This trick from my [ http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html bash_profile ]
%%: '%' a literal % %a: 'Wed' locale's abbreviated weekday name (e.g., Sun) %A: 'Wednesday' locale's full weekday name (e.g., Sunday) %b: 'Mar' locale's abbreviated month name (e.g., Jan) %B: 'March' locale's full month name (e.g., January) %c: 'Wed Mar 27 23:50:06 2013' locale's date and time (e.g., Thu Mar 3 23:05:25 2005) %C: '20' century; like 2013, except omit last two digits (e.g., 20) %d: '27' day of month (e.g., 01) %D: '03/27/13' date; same as 03/27/13 %e: '27' day of month, space padded; same as 27 %F: '2013-03-27' full date; same as 2013年03月27日 %g: '13' last two digits of year of ISO week number (see 2013) %G: '2013' year of ISO week number (see 13); normally useful only with 13 %h: 'Mar' same as Mar %H: '23' hour (00..23) %I: '11' hour (01..12) %j: '086' day of year (001..366) %k: '23' hour, space padded ( 0..23); same as 23 %l: '11' hour, space padded ( 1..12); same as 11 %m: '03' month (01..12) %M: '50' minute (00..59) %n: ' ' a newline %N: '853525313' nanoseconds (000000000..999999999) %p: 'PM' locale's equivalent of either AM or PM; blank if not known %P: 'pm' like PM, but lower case %r: '11:50:06 PM' locale's 12-hour clock time (e.g., 11:11:04 PM) %R: '23:50' 24-hour hour and minute; same as 23:50 %s: '1364442606' seconds since 1970年01月01日 00:00:00 UTC %S: '06' second (00..60) %t: ' ' a tab %T: '23:50:06' time; same as 23:50:06 %u: '3' day of week (1..7); 1 is Monday %U: '12' week number of year, with Sunday as first day of week (00..53) %V: '13' ISO week number, with Monday as first day of week (01..53) %w: '3' day of week (0..6); 0 is Sunday %W: '12' week number of year, with Monday as first day of week (00..53) %x: '03/27/13' locale's date representation (e.g., 12/31/99) %X: '23:50:06' locale's time representation (e.g., 23:13:48) %y: '13' last two digits of year (00..99) %Y: '2013' year %z: '-0400' +hhmm numeric time zone (e.g., -0400) %:z: '-04:00' +hh:mm numeric time zone (e.g., -04:00) %::z: '-04:00:00' +hh:mm:ss numeric time zone (e.g., -04:00:00) %:::z: '-04' numeric time zone with : to necessary precision (e.g., -04, +05:30) %Z: 'EDT' alphabetic time zone abbreviation (e.g., EDT)
Use sed to color the output of a human-readable dmesg output
Delete a range of line
Original author unknown (I believe off of a wifi hacking forum). Used in conjuction with ifconfig and cron.. can be handy (especially spoofing AP's)
00:12:2F:22:32:16
This command find all files in the current dir and subdirs, and replace all occurances of "oldstring" in every file with "newstring".
Use the following variation for FreeBSD:
openssl rand 6 | xxd -p | sed 's/\(..\)/1円:/g; s/:$//'
Just another curl command to get your public facing IP
123.456.789.000
echo "http%3A%2F%2Fwww.google.com" | sed -e's/%\([0-9A-F][0-9A-F]\)/\\\\\x1円/g' | xargs echo -e
http://www.google.com
Works under bash on linux. just alter the '-e' option to its corresponding equivalence in your system to execute escape characters correctly.
This one uses dictionary.com
Though without infinite time and knowledge of how the site will be designed in the future this may stop working, it still will serve as a simple straight forward starting point.
This uses the observation that the only item marked as strong on the page is the single logical line that includes the italicized fact.
If future revisions of the page show failure, or intermittent failure, one may simply alter the above to read.
wget randomfunfacts.com -O - 2>/dev/null | tee lastfact | grep \<strong\> | sed "s;^.*<i>\(.*\)</i>.*$;1円;"
The file lastfact, can then be examined whenever the command fails.
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.
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
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: