My random Ramblings

Category: Uncategorized

Some useful bash hacks

Useful Bash Hacks

So, listed below are some of my favorite bash commands that I use very frequently.

1) Move all files of a particular type in a directory

The command below searches for all the zip files in a particular directory hierarchy and moves it to a new directory. The depth of the search can be adjusted with the maxdepth option for the find command. I often use this to clean up my Desktop.

find ./ -name “*.zip” -exec mv {} ./zipped_files    \;

For all files in a the current directory and to ignore sub-directories  –

find ./ -name “*.zip” -maxdepth 1 exec mv {} ./zipped_files    \;

2) Modify each line in a text file

The sed command is pretty useful for all kinds of stream editing. Lets say I want to surround each line in a file with a html tag. This can be easily done via the sed command. Lets say I want enclose an XML tag for each line in a text file, sed makes this pretty easy.

Input File





The command which I am going to use is

sed 's:.*:<id>&</id> sample.txt > new_file.txt

And the output file would be


3) Cut command Example

Again, this is a pretty common hack. List all users in the system along with their home directories

cut -d : -f 1,6 /etc/passwd


Playing around with Ubigraph-NetworkX Library in Python

I have been interested in social media visualization for quite some time. I was looking for some great visualization tools for python based graphs. I was extremely impressed by Ubigraph’s Visualization tools (http://ubietylab.net/ubigraph/). It has a pretty awesome graph visualization UI. the coolest thing which python users will love about will be its integration to another awesome graph library in Python (http://networkx.lanl.gov/). It is a great tool for modeling complex networks.These two tools are gonna make hacking social media data so much fun 🙂

In my next post we’ll see a use a simple script to visualizing twitter data as interactive graphs

Liverpool Vs Chelsea :)

I just finished watching the Liverpool kicking Chelsea’s ass and as Red’s fan, I could ‘nt have asked for something better 🙂 .!! And What a Match it was ..!!! Chelsea having bought some of the two best Ex-Liverpool players in Torres and Mereiles and still getting a goal scored against them by Glenn Johnson was one of the biggest ironies:) ..!! Kenny Dalglish made an awesome first team lineup in choosing Rodriguez over Downing and how well did it pay off 🙂 . Well a great day to be a Reds’ Fan.

YNWA ..!!!!

Hello world!

Welcome to WordPress.com. After you read this, you should delete and write your own post, with a new title above. Or hit Add New on the left (of the admin dashboard) to start a fresh post.

Here are some suggestions for your first post.

  1. You can find new ideas for what to blog about by reading the Daily Post.
  2. Add PressThis to your browser. It creates a new blog post for you about any interesting  page you read on the web.
  3. Make some changes to this page, and then hit preview on the right. You can always preview any post or edit it before you share it to the world.