As the doctor gone rogue

October 15, 2016

Find files and listing details on Linux

Filed under: bash, miscellaneous, ubuntu — Tags: , , , , , — hypotheses @ 12:01 pm

One common task that we always have to do relatively often is to find the location of some specific files. Although you may have some clues that those files are located in your current working directory, “.” symbolic link used in the command below, you may have no clue to which sub-folder your files are.

(more…)

Advertisements

October 9, 2015

apt-get error with … for package ‘linux-headers-3.2.0-60’ is missing final newline

Filed under: Uncategorized — Tags: , , , — hypotheses @ 7:49 am

I recently clone a virtual machine image and setting up locally. When trying to install a new package through <code>apt-get</code> in Ubuntu. I ran into a strange problem of “missing final newline” in linux-headers.

Trying to google for solution, I found a page in 2004 mentioning this problem. It suggested that a file in /var/lib/dpkg/info/smbf.list is the cause of the error. So, I tried to locate this file but without any success.

I notice that there is “linux-headers-3.2.0-60.list” and a few other files with similar names in this folder. So, well, why not trying to delete them.

It seems like deleting these files fix the problem and allow apt-get to install the package without any problems. So far the system seems normal. We haven’t allowed any additional access through the server, only deleting a few files that don’t look essential for the OS to run.

Further remove other apt-get unused file through apt-get clean seems to solve the problem.

February 20, 2014

Download files from a webpage with wget.

Filed under: bash — Tags: , , — hypotheses @ 9:15 pm

Recently phylotree just release another update of mitochndrial phylogentic trees (19Feb2014). Besides the updated tree, a very nice feature of http://www.phylotree.org website is that they have a great curation of mitochondrial sequences publicly available for download. You can check out their website here http://www.phylotree.org/mtDNA_seqs.htm

If you have a curious mind, you may want to download all the sequences, construct your own trees or use the data to do something else creatively.

In this case wget might be your best friends, although you might be able to write a python script to do something similar.

 wget -r --accept "*.ext" --level 2 http://www.website.com/pagewithLink.html
 

As a reminder, if you are behind a proxy firewall, take a look at my previous post  https://bhoom.wordpress.com/2013/07/26/how-to-wget-with-proxy-authentication/

 

March 2, 2011

Using cut to extract specific columns from a fixed-width format file

Filed under: bash, data management — Tags: , , , , — hypotheses @ 12:07 pm

Occasionally, I will have to deal with a text file in a fixed width text format. In Linux, you can extract specific columns easily using cut

cut -b 1-10,15-20 < infile

This will give you column 1-10 and 15-20 of your “infile”

The additional option that is nice when you want to get rid of a few columns and keep the rest of them is using the option –complement (although from what I have heard, some systems might not have this implemented).

cut –complement -b 11,14,32,43-47,58-62,73-77,88-92,103-108 < infile

Other use of cut is to extract columns from any other type of file with delimiter such as “,” or space

by adding the option -d”_your_delim_” to the example above, and you can extract your infile.csv or infile.txt as well.

 

Create a free website or blog at WordPress.com.