Reading file/folder path in bash

Sometime back, was working with a colleague and came across a new requirement. We needed a script that takes a path as input. (It is an interactive shell script) The catch is, we wanted to provide some flexibility for the user and so we wanted the path to be auto-completed. (tab fills up the path)

When we tried “read -e path” and “echo $path“.. it didn’t help :( So, we did a “man read” and found that read can store the input in REPLY variable and you can use it.

read -e
echo $REPLY

This worked.. When we used tabs, it auto-filled and we can use REPLY variable to get the input.  This was tried on an SLES machine. When I tried “read -e path” on ubuntu, auto-completion itself worked. So, looks like the auto-completion is different between SLES and Ubuntu..

Moral of the story: (Apart from Ubuntu is convenient), read stores the input in REPLY variable and that can be used in your scripts :)

Nemo Actions (Comparing Multiple files)

If you had followed the steps in my previous post, by now, your nemo will be able to select a file and compare it with another file. If you think it should also have the ability to compare multiple files when you select them, Go ahead. Read on!!!

Now, you need copy the content below to $HOME/.local/share/nemo/actions/compare-multi.nemo_action

[Nemo Action]
Name=Compare selected items
Comment=Compare %F saved file or directory.
Exec=/usr/bin/meld %F

Nemo Actions (Comparing Single file)

I have been using Nemo as my file browser for almost a year now.. Since nautilus lost the most used features and started assuming things that I never intended to…

Recently, I had to do a comparison of a few text files and had to go to console and open the diff viewer.. Thought, what if nemo had this ability in itself (something like in the right click menu).. Started searching for it and found a link that talked about how this can be accomplished.


You need to create the following files (along with their contents) in .local/share/nemo/actions under your home directory. (System wide location : /usr/share/nemo/actionsI haven’t tried it yet though.. But, it should work.)

nemo_action files are the files that creates menu entries in the pop-up dialog that comes up when you right click. These files are read by nemo whenever you right click. The syntax is similar to a .desktop file. You can invoke a script from these nemo_action files that does your job. If you want to change the script, feel free to do so. And to verify your changes, all you have to do it save the changes and right click on nemo :).. (I know how happy a software engineer will be for not having to wait for testing their changes)

You can have a look at /usr/share/nemo/actions/sample.nemo_action and /usr/share/nemo/actions/ These files have detailed information on what each field in the action files indicates. Really simple and useful :)

We are going to add options to:

  • Select for comparison (We are selecting a file that we need to compare with)
  • Compare with selected file (Compare with the file selected in previous step. This option will be visible only when a file has been already selected for comparison.)

How are are going to add those options?

Simple. Do what we have been doing all these years (In short, Copy Paste) the exact content given below as it is. It will work :)

Lets get into action:


[Nemo Action]
Name=Compare later
Comment=Save file for comparison later.
Exec=< save %F>


[Nemo Action]
Name=Compare with saved element
Comment=Compare %F saved file or directory.
Exec=< compare %F>



if [ -L $0 ] ; then
DIR=$(dirname $(readlink -f $0)) ;
DIR=$(dirname $0) ;

if [ "$1" == "save" ]; then
echo “$2″ > “$savedfile”
chmod 700 $savedfile
“$comparator” $(cat “$savedfile”) “$2″ &
mv $DIR/compare-with-saved.nemo_action $DIR/compare-with-saved.nemo_action1
rm -f $savedfile

if [ -f $savedfile ]; then
mv $DIR/compare-with-saved.nemo_action1 $DIR/compare-with-saved.nemo_action


If you think your file names may contain spaces in them, then you can add Quote=double to the nemo_action files mentioned above. Nemo encapsulates each path in double quotes and passes it to the diff viewer.

Buddy Pounce!!!

How many times, you had to ping somebody and (s)he is offline and you want to be notified when (s)he comes online so that you can continue doing what you were doing instead of keep on checking whether (s)he has come online or not!!!

My first long sentence after a loooooong time!!!

In Pidgin, you can Select a buddy and “Add Buddy Pounce…”. It gives a load of options on when you want (somebody comes online/sends message/becomes idle……….)to do what (Send a message/Popup a notification…..)

Kool feature that I liked :) It helped me solve a problem that I have mentioned in one of my looooongest sentences :D

Wimbledon 2014 – Kyrgios vs Nadal

Just now finished watching this match and decided to write this post.

Had some work and so could not watch the 1st set. When I saw the players, I thought “Nadal vs some unknown guy.. The result is obvious…” and decided to watch it for sometime and see how the unknown guy looses. Slowly, it started interesting especially because of Kyrgios’s serves.. This became more interesting when I came to know that this guy is just 19. Yes NINETEEN!!! Some of his serves were of 129mph (207 KMph). Everybody knows how Nadal plays and even he couldn’t touch most of the serves and had to just keep seeing the ball go past him. When we look at the number of Aces, it is close to 35 by Kygrios.

World No. 1 Vs a Nineteen year old… and the Nineteen year old won.. Can you believe it?? Simply superb game.. Happy to have watched this :)

Well done Kyrgios and hope to see you in the Semis as well :)


I always liked Dhoni for being cool and calm even when somebody drops a simple catch at the crucial stage of a match. Today got another reason to like him.. Him and Faf Du Plessis were in 48 and 2 runs needed to win the match. He took a single and gave an opportunity to Faf to complete his 50. I don’t know how many people will do it.. Simple GREAT and SALUTE to this gesture :)

Good One DHONI!!! One more leadership skill that we can learn from him :)

Chocolates for balance

Interesting title? Sounds scientific ?? Actually, this is a stinker :(

How many times you have spent 18 Rupees and you have given the shopkeeper a 20 Rs Note. And can anybody tell me what you get for balance?? CHOCOLATES !!! And this is happening for the past few years in India.. And I <fill up with whatever non-parliamentary word comes to your mind here> hate this. If I want chocolates, I’ll buy them. The shopkeeper doesn’t have to tell me that I have to buy chocolates.

Recently, I heard that, even the bus conductors started doing this. It is my right to get the balance and they have no right to deny it. In my office cafeteria, the person has bought stuff only for this purpose. I am 100% sure he makes a minimum of 200+ rupees per day on chocolates.

I always insist on getting my money back instead of those chocolates. If he doesn’t have the money, I’ll ask him to keep it in mind and balance it in my next visit.

The worst part is, if we give them chocolates, why are they accepting? Who authorized them to give chocolates? People think that it is just 1 or 2 Rupee and get the chocolates. But, do they realize that each time they are loosing that 1 or 2 rupee buying things unnecessarily?


Mount ZIP files as folders

Recently, I had to extract a particular file inside a zip file. So, what I had to do is, I have to download the zip file, extract it and copy the file. Or use some GUI tool to open the zip file and have a look at it contents and extract only the file I need. I know that we can mount the iso files to a folder and view its contents. As iso files and zip files are similar in nature (ie. has multiple files/folders inside them), I thought whether I can mount it and copy only the file that I need.

And, after searching a bit, I came across fuse-zip. This is a kool tool and it is also part of ubuntu software repositories.

Couple of features I liked:

  • Obviously, the main purpose, I can mount a zip file to a folder and access it like any other folder.
  • Now comes the best part: If you have modified the content of a file or folder, once you unmount the folder, Guess what?? It includes your changes into the zip file :) (Be careful when you are using editors that create backup files when you started editing a file and I don’t think you want to include them in the zip files when you create them)

After using this for some time, I became a fan of it :)

I think this is how fuse works: (Being a Java developer, I am writing in those terms.) Fuse provides an interface to which different handlers can register them selves. These handlers should be responsible for understanding the file systems. These file system can be zip files, iso files, ssh session, or even a database :) The handlers can have the logic to translate the linux commands (changing/moving/deleting directories) that the user provides to the one appropriate for the underlying filesystem.

Kool.. isn’t it??

Kalki’s Ponniyin Selvan

I successfully finished reading Ponniyin Selvan (2nd time). This is not going to be a review. Just what I felt.

This is not a story about how RajaRaja Chola became a king. This is about the events happened before that. The writing is so great that, Raja Raja Chola will be introduced “as a character himself” only in the middle of 2nd volume (out of 5 volumes). Till then, he will be mentioned. By the time the introduction was made, I started admiring Raja Raja Chola and eagerly waiting for the introduction to happen :) If at all this was made as a movie, by the right people, the introduction scene can create the same (or even more) effect as Baasha interval scene. It has the potential. The climax is wonderful.

At times, it has great humour. Also, there are some big suspenses. But, I still could not get an answer for one big question.. Who is the real ___ of ___ ? Sorry… I cannot fillup the blanks without revealing a suspense :D But, you will be able to guess this when you read the book. If you know the answer, do let me know. The character says something.. but, the circumstances seems to be totally different.

This book also shows us the respect people had on Thirukkural. Loved it more than the first time.. I think each time I read it, I get more involved. I don’t know when, But I’ll read it again.. :) If you have time, I recommend you READ IT. If you don’t have time, FIND TIME AND READ IT !!

Cricket – IPL 2014

After watching yesterday’s IPL match between RCB and MI, this is the line that came to my mind: (Of course it was inspired by some tweet message that they read out on TV)

In cricket only bat and ball should fight/clash, not the players holding them!!

Cummon Starc and Pollard.. Grow up :)


Get every new post delivered to your Inbox.