Archive

Posts Tagged ‘bash’

How to select odd (or even ) raws from a text file using the bash

January 27th, 2012 No comments

Yesterday I had to select some raws (1, 5, 9, ….) from a text file.

This has been a hard job because I was trying to solve the wrong problem……

Really, before coding you should analyze deeply your problem and then you should think which tool you need to use.

However, come on and see my experiments:

First of all we need a test file, I'll use the following:

3 ways to remove duplicate lines from a text file

December 27th, 2011 No comments

 

One of the more diffcult job, while using the shell, is working with text files to filter their content.


In the following few lines you will find 3 different ways to remove all the duplicate lines from a text file.


First of all, I'll introduce three commands that are available on almost all of the linux distributions, and maybe in all Unix dialects:

uniq

Discard all but one of successive identical lines from INPUT (or standard input), writing to OUTPUT (or standard output).

 

Twidge: A flexible way to gain the access to Twitter resources

December 9th, 2011 No comments

Twidge is a full command-line client. It is designed to be useful when you’re sitting at a shell prompt. It’s also designed to work well with the Unix/POSIX/Linux shell scripting environment. It produces output in well-formed and easily-parsed ways, and has various features for working with piped data.

How to create a ramdisk on Mac OS X Snow Leopard

September 27th, 2011 No comments

From the wikipedia

"A RAM disk or RAM drive is a block of RAM that a computer's software is treating as if the memory were a disk drive.

….

….

….

How to install Midnight Commander on Snow Leopard

May 15th, 2011 No comments

GNU Midnight Commander is a user-friendly yet powerful file manager and visual shell, useful to novice and guru alike. It provides a clear, user-friendly, and somewhat protected interface to a Unix system while making many frequent file operations more efficient and preserving the full power of the command prompt.

A simple tool to modify initrd and rootfs

March 11th, 2011 No comments

 

If you want to customize a distribution to boot only on your particular computer you should be able to modify the initrd and rootfs files.

Mac OS X: colorizing ls result

November 2nd, 2010 No comments

On Mac OS X you could give colors to the output of the "ls" command simply adding an alias:

# alias ls ='ls -G'

also you can show a / at the end of a directory name using the -p switch

# alias ls='ls -p'

How to remove all files generated by an extracted tar archive

December 24th, 2009 No comments

Often I use tar files downloaded from the internet, sometimes these files don't include a directory containing all other files and directories, so it's very tedious removing all files generated by the extraction, but I can use the following command to remove all the files generated:

Categories: Bash Tip & Tricks, linux Tags: , , ,

Using xargs to parallelize and speed up jobs.

December 8th, 2009 No comments

Often we look for new way to boost up our work, so we write a lot of code to perform jobs at high speed.
Sometimes the right way is the old way, specially if we need to do repetitive jobs. To do this kind of jobs we can use the xargs command, this command used in pipe with other commands can automate our jobs.
For example if we want to remove all C files from a directory and from all subdirectory recursively we can do the following:

Removing a type of file recursively.

October 11th, 2009 No comments

Sometimes during my work I need to remove a set of files from a big directory tree. For example when I develop a driver or an application and I want to distribute to my customers only the obj files and the documentation files (README.txt, INSTALL.txt, LICENSE.txt, Makefile ……) I need to remove all my source code (*.c and *.h), this is a very tedious task, but I can use the bash to do this task for me, and I’m quite sure that bash doesn’t forget any files.
 

Categories: Bash Tip & Tricks, UNIX TLC Tags: ,
Statistical data collected by Statpress SEOlution (blogcraft).