unbound variable – bash completion not working and having issues with other stuff like command not found.

2010-03-23 1 min read Bash Learning Linux

I generally use vi/vim for all my practical purposes of working with text files. And I have all the vi/vim plugins required to work with the files. This causes the following to be in the skeleton for all the bash scripts that I create:

set -o nounset                              # Treat unset variables as an error

With this all the unbound variables as errors and was problem with all the shell scripts that was being sourced in the startup of bash. So all I had to do was remove this from all the startup scripts and then from the skeleton of the bash script in vim :).

Continue reading

Useless Linux Terminal Commands

2010-03-21 1 min read Bash Linux

Useless Linux Terminal Commands Not long ago, I have listed here some useful Linux terminal commands and those that I described as deadly. This time, I decided to gather some commands that I think have no practical use. I know it sounds interesting but you may disagree with me on some of the commands that I’ll list here as you may find a few of them useful. We can however agree to disagree as long as you explain to us why or how you find them handy.

Continue reading

What is my ip?

2010-03-14 1 min read Bash

$ alias whatismyip="wget -q -O - <a href="http://whatismyip.com/automation/n09230945.asp"">http://whatismyip.com/automation/n09230945.asp" The preferred way for scripts (and easier to parse)

  • <a href="http://www.commandlinefu.com/commands/view/3943/what-is-my-ip">View this command to comment, vote or add to favourites
  • <a href="http://feeds2.feedburner.com/commands/by/gibboris">View all commands by <a href="http://feeds2.feedburner.com/commands/by/gibboris">gibboris

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

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

URL: <a href="http://feedproxy.google.com/~r/Command-line-fu/~3/O6l8r0uDeTc/what-is-my-ip">http://feedproxy.google.com/~r/Command-line-fu/~3/O6l8r0uDeTc/what-is-my-ip

Some bashrc shorcuts for faster and profiecient directory browsing.

2010-03-10 1 min read Bash Linux

Here are some of the funtions that I have in my bashrc to make my life simple. They are not written by me but mostly taken from other places, but modified by me to some extent to suit my needs. If you know the original creator of these, let me know so I can add the attribution for the same.

This one is very useful.

.. (){
local arg=${1:-1};
local dir=&#8221;&#8221;
while [ $arg -gt 0 ]; do
dir=&#8221;../$dir&#8221;
arg=$(($arg – 1));
done
cd $dir >&/dev/null
}

Continue reading

Bash script to view log and config file in different server and paths.

2010-03-09 1 min read Bash

I was working on a project, where I need to open file from different servers and different paths. I do it with the command:

vim ftp://username@server/path/filename

This is okay when the path is short but when the path gets longer and I have different config files to open from the same path or their associated logs, then it becomes un-necessary typing. So, I did the following:

Have a file with some aliase&#8217;s like the below and source it from the bashrc file:

Continue reading

Bash histoy – common history in different terminals

2010-03-04 1 min read Bash Linux

I have been looking to do this for sometime. The bash history is per
session basis and the last session to quit overwrites the bash_history
file and thus all other terminals started between the time last terminal
lasted does not get to write the commands in the history file. Secondly
the history gets cluttered with lot of duplicate entries and entries
with ls and cd commands. So finally I added these to the bashrc file:

Continue reading

Bash Sub Shells

2010-03-02 1 min read Bash

Taken from <a href="http://www.linuxjournal.com/content/bash-sub-shells" target="_blank">here.

<span class=\"c\">#!/bin/bash</span>

<span class="nv">server_cmd</span><span class="o">=</span>server <span class="nv">pid_file</span><span class="o">=</span><span class="k">$(</span>basename <span class="nv">$server_cmd</span> .sh<span class="k">)</span>.pid <span class="nv">log_file</span><span class="o">=</span><span class="k">$(</span>basename <span class="nv">$server_cmd</span> .sh<span class="k">)</span>.log

<span class="o">(</span> <span class="nb">echo</span> <span class="s2">"Starting server"</span> <span class="nb">echo</span> <span class="s2">"Doing some init work"</span> <span class="nv">$server_cmd</span> <span class="c"># server becomes a daemon</span>

&lt;span class=\"k\">while &lt;/span>&lt;span class=\"nb\">true&lt;/span>

<span class="nb"> </span><span class="k">do</span> <span class="k"> if</span> <span class="o">[[</span> -f <span class="nv">$pid_file</span> <span class="o">]]</span>; <span class="k">then</span> <span class="k"> </span>sleep 15 <span class="k">else</span> <span class="k"> </span><span class="nb">break</span> <span class="nb"> </span><span class="k">fi</span> <span class="k"> done</span> <span class="k"> </span>mail -s <span class="s2">"Server exitted"</span> joe@blow.com <<<CRAP

Continue reading
Older posts Newer posts