Pipe stdout and stderr, etc., to separate commands
$ some_command > >(/bin/cmd_for_stdout) 2> >(/bin/cmd_for_stderr) You can use [n]> combined with >(cmd) to attach the various output file descriptors to be the input of different commands.
$ some_command > >(/bin/cmd_for_stdout) 2> >(/bin/cmd_for_stderr) You can use [n]> combined with >(cmd) to attach the various output file descriptors to be the input of different commands.
Easier Reinstalls
I typically reinstall my computer operating system every six months. The reasons for this are that it cleans out the system and reinstalls require me to be in front of the computer for a total of about ten minutes so it’s painless. Notice I said ”in front of the computer”, the system does all of the work for me with some specially crafted bash scripts.
Continue readingIn the <a class="zem_slink freebase/en/bash" title="Bash" rel="homepage" href="http://tiswww.case.edu/php/chet/bash/bashtop.html">bash version 4.0, there is a new concept called coproc. This is very useful for some of the daily tasks.
co-<a class="zem_slink freebase/guid/9202a8c04000641f800000000005a409" title="Process (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Process_%28computing%29">process starts a process in the background, optionally with a NAME, with which other processes can communicate. This can be a very <a class="zem_slink freebase/en/substitute_good" title="Substitute good" rel="wikipedia" href="http://en.wikipedia.org/wiki/Substitute_good">good substitution for <a class="zem_slink freebase/guid/9202a8c04000641f800000000048fac5" title="Pipeline (Unix)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Pipeline_%28Unix%29">pipes in lots of cases. You can learn more about coproc in the link below:
Continue readingBeen pretty busy for last couple of days. Will be busy for another few days, but here’s something to munch in the meantime (Script may need changes depending on the type of file you want to download or the site you are browsing, but the chnages should be minimal):
file=”/tmp/temp.dir”
Continue reading
url=”URL Here”
IFS=’
’
cont=”y”
while [ $cont != ”n” ]
do
name=””
wget ”$url” -O $file -o /dev/null
for i in $(grep href $file |grep -v Parent)
do
name=${i##href=”}
name=${name%%”>}
echo $name
if [[ $name == *gz ]]
then
cont=”n”
fi
done
if [ ! $name ]
then
echo ”No files here.. Exiting”
exit -1
fi
echo
if [ $cont == ”n” ]
then
echo ”Enter the filename for download :”
read file
fi
echo ”Select one of the options:”
read product
url=”$url/$product”
echo ”About to get $url”
done
wget ”$url” -O $file -o /dev/null
$ rm !(.foo|.bar|*.baz)
Deletes all files in a folder that are NOT *.foo, *.bar or *.baz files. Edit the pattern inside the brackets as you like.
<a href="http://www.commandlinefu.com"><img src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/header-logo.jpg" alt="" align="bottom" />
by David Winterbottom (<a href="http://codeinthehole.com">codeinthehole.com)
<a href="http://feedads.g.doubleclick.net/~a/kewaFMgsXI4A1vQfeLscg2Vcv8o/0/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/kewaFMgsXI4A1vQfeLscg2Vcv8o/0/di" alt="" align="bottom" />
<a href="http://feedads.g.doubleclick.net/~a/kewaFMgsXI4A1vQfeLscg2Vcv8o/1/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/kewaFMgsXI4A1vQfeLscg2Vcv8o/1/di" alt="" align="bottom" />
<img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~r/Command-line-fu/~4/TCRb2ku_V1Y" alt="" width="1" height="1" align="bottom" />
Continue readingThere is a calculator called bc that works in the command line. So if you need a quick calculator function in the command line then you could write some functions that will do the trcik for you. Here is an example:
Continue readingGo to the directory which you want to add to cvs and execute the following:
cvs login
find . -type d -exec cvs add {} \;
find . -type f -exec cvs add {} \;
cvs commit
That was simple 🙂