Check These Out
This is a command to be used inside of MS-DOS batch files to check existence of commands as preconditions before actual batch processing can be started. If the command is found, batch script continues execution. If not, a message is printed on screen, script then waits for user pressing a key and exits.
An error message of the command itself is suppressed for clarity purpose.
% acts on every line in the file.
\s matches spaces.
\+ matches one or more occurrences of what's right behind it.
Character '$' matches end-of-line.
jhead is required
I wasted two hours reading the sox documentation and searching on the web for the format of some obscure fscking sound sample, and then finally came up with this. This plays only the first three seconds of your unknown formatted sound file using every one of sox's built-in filetypes. If you don't get an exact match, you may get close.
.
I could not fit every single type in and keep it under 127 characters, so you will have to replace "..." with the full list obtainable by `$ sox --help` (or try `Show sample output`)
.
note: /usr/bin/play should be linked to sox on most systems.
A shorter version
One of my favorite ways to impress newbies (and old hats) to the power of the shell, is to give them an incredibly colorful and amazing version of the top command that runs once upon login, just like running fortune on login. It's pretty sweet believe me, just add this one-liner to your ~/.bash_profile -- and of course you can set the height to be anything, from 1 line to 1000!
$ G=$(stty -g);stty rows $((${LINES:-50}/2));top -n1; stty $G;unset G
Doesn't take more than the below toprc file I've added below, and you get all 4 top windows showing output at the same time.. each with a different color scheme, and each showing different info. Each window would normally take up 1/4th of your screen when run like that - TOP is designed as a full screen program. But here's where you might learn something new today on this great site.. By using the stty command to change the terminals internal understanding of the size of your terminal window, you force top to also think that way as well.
# save the correct settings to G var.
$ G=$(stty -g)
# change the number of rows to half the actual amount, or 50 otherwise
$ stty rows $((${LINES:-50}/2))
# run top non-interactively for 1 second, the output stays on the screen (half at least)
$ top -n1
# reset the terminal back to the correct values, and clean up after yourself
$ stty $G;unset G
This trick from my [ http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html bash_profile ], though the online version will be updated soon. Just think what else you could run like this!
Note 1: I had to edit the toprc file out due to this site can't handle that (uploads/including code). So you can grab it from [ http://www.askapache.com/linux-unix/bash-power-prompt.html my site ]
Note 2: I had to come back and edit again because the links weren't being correctly parsed
Nothing fancy it just converts one file from one character encoding into another one.
Working with log files that contains variable length messages wrapped between open and close tags it may be useful to filter the messages upon a keyword.
This works fine with GNU sed version 4.2 or higher, so pay attention to some unix distros (solaris, hp-ux, etc.).
Linux should be ok.
For this hack you need following function:
$ finit() { count=$#; current=1; for i in "$@" ; do echo $current $count; echo $i; current=$((current + 1)); done; }
and alias:
$ alias fnext='read cur total && echo -n "[$cur/$total] " && read'
Inspired by CMake progress counters.