Download with browse with bash and wget

2010-05-09 1 min read Bash Fedora

Been 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”
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

Continue reading

bash script to periodically change the cursor theme.

2010-05-07 1 min read Fedora GNOME

#!/bin/bash
[[ ”$1” == ”” ]] && time=5 || time=$1
[[ ”$2” == ”” ]] && (
cd ~/.icons
cont=”y”
echo ”Select one of the icon themes”
echo ”When you like some theme just press Ctrl+c”
for i in *
do
[[ -d $i/cursors ]] && (
echo ”Now trying …. : $i”
gconftool-2 –type string -s  /desktop/gnome/peripherals/mouse/cursor_theme ”$i”
sleep $time
)
done
) || gconftool-2 –type string -s  /desktop/gnome/peripherals/mouse/cursor_theme ”$2”

Continue reading

xterm – select font name and size from command line and set it as default

2010-05-05 2 min read Fedora Linux

I have been very busy last week and specially yesterday with 20 hours of continueous work, but managed to get this working :).

When you right click on Xterm with Ctrl pressed, there pops up a menu for selecting the size of the font. I have always wondered how to set this as default font and/or use this from the command line. So I searched my old homedir and looked for few of the docs that I had to get the information. Here is what I found.

Continue reading

Quick notepad in bash without any editor

2010-04-12 1 min read Bash

$ «.>note Bash internal quick note taker, avoiding calling external programs like cat

  • <a href="http://www.commandlinefu.com/commands/view/3939/quick-notepad">View this command to comment, vote or add to favourites
  • <a href="http://feeds2.feedburner.com/commands/by/netizen">View all commands by <a href="http://feeds2.feedburner.com/commands/by/netizen">netizen

<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/aAyNWJ1rcV4brCukeWT51QSbCZs/0/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/aAyNWJ1rcV4brCukeWT51QSbCZs/0/di" alt="" align="bottom" />
<a href="http://feedads.g.doubleclick.net/~a/aAyNWJ1rcV4brCukeWT51QSbCZs/1/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~a/aAyNWJ1rcV4brCukeWT51QSbCZs/1/di" alt="" align="bottom" />

<img src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/~r/Command-line-fu/~4/luL4fGyQxqk" alt="" width="1" height="1" align="bottom" />

URL: <a href="http://feedproxy.google.com/~r/Command-line-fu/~3/luL4fGyQxqk/quick-notepad">http://feedproxy.google.com/~r/Command-line-fu/~3/luL4fGyQxqk/quick-notepad

Linux Shell Scripting Tutorial – A Beginner\’s handbook

2010-04-11 0 min read Bash Learning Linux
\"Tux,
Image via Wikipedia

<a class="zem_slink freebase/en/unix_shell" title="Unix shell" rel="wikipedia" href="http://en.wikipedia.org/wiki/Unix_shell">Linux Shell Scripting Tutorial – A Beginner&#8217;s handbook —

This book is for students and Linux System Administrators. It provides the skills to read, write, and debug <a title="Linux" href="http://bash.cyberciti.biz/guide/Linux">Linux <a class="zem_slink freebase/en/shell_script" title="Shell script" rel="wikipedia" href="http://en.wikipedia.org/wiki/Shell_script">shell scripts using <a title="Bash" href="http://bash.cyberciti.biz/guide/Bash">bash <a title="Shell" href="http://bash.cyberciti.biz/guide/Shell">shell. The book begins by describing <a title="Linux" href="http://bash.cyberciti.biz/guide/Linux">Linux and simple scripts to automate frequently executed commands and continues by describing conditional logic, <a class="zem_slink freebase/en/interactivity" title="Interactivity" rel="wikipedia" href="http://en.wikipedia.org/wiki/Interactivity">user interaction, loops, menus, traps, and functions. Finally, book covers various sys admin related scripts such as making a backup, using <a class="zem_slink freebase/guid/9202a8c04000641f80000000045c9c5b" title="Cron" rel="wikipedia" href="http://en.wikipedia.org/wiki/Cron">cron jobs, writing interactive tools, web based tools, remote login, ftp and database backup related scripts. This book is intended for Linux <a class="zem_slink freebase/en/system_administrator" title="System administrator" rel="wikipedia" href="http://en.wikipedia.org/wiki/System_administrator">system administrators or students who have mastered the basics of a Linux Operating System. You should be able to:

Continue reading

Jokes – many to be downloaded once..

2010-04-11 1 min read Bash Fedora Linux

All work and no fun makes Jack dull boy. So lets do something for fun. Here is a one liner I wrote sometime back.  The original idea is not mine and I don&#8217;t remeber where I got the idea from but it was some other one liner that I was browsing for some oracle query. Anyway here&#8217;s the one liner to get lot of jokes in one file.

#!/bin/bash
for i in `echo 000{0..9} 00{10..99} 0{100..999} {1000..1600}` ; do links -dump http://www.robsjokes.com/$i/index.html | sed &#8217;/Random Joke/,/Next Joke/!d&#8217; | sed &#8217;/^$/,/^$/!d&#8217; » ~/Rob.jokes ; echo &#8217;%&#8217; » ~/Rob.jokes ;echo $i; done

Continue reading

Bash completion error — quote_readline.

2010-04-11 1 min read Bash

There is a problem with bash completion with quote_readline that causes the completion to fail. The problem is fixed in the bash completion package but there are still some other programs which are using the problematic code. Here is a way to find and resolve it.

First find the problematic program, most likely the recent one after which you started having the problems. Once that is found, find the file containing the definition of the function &#8221;_filedirs()&#8221;. Now, delete this file and create a symbolic link to the bash_completion file in the /etc directory. If this file is not present then you need to install the bashcompletion package.

Continue reading
Older posts Newer posts