Find the size of a directory: du -sh dirname/

Tail like command for windows using Windows Powershell to extract last few lines of a large text file:

Get-Content "inputfile.txt" -Wait -Tail 3000 > tail.txt

 

Useful Linux Navigating Commands

Zip a folder (and exclude a sub-folder)

zip -r myarchive.zip dir1 -x dir1/ignoreDir1/**\* dir1/ignoreDir2/**\*

  • To remove a folder with all its contents (including all interior folders):

    rm -rf /path/to/directory
    
  • To remove all the contents of the folder (including all interior folders) but not the folder itself:

    rm -rf /path/to/directory/*
    

    or, if you want to make sure that hidden files/directories are also removed:

    rm -rf /path/to/directory/{*,.*}
    
  • To remove all the "files" from inside a folder(not removing interior folders):

    rm -f /path/to/directory/{*,.*}
    

Warning: if you have spaces in your path, make sure to always use quotes.

rm -rf /path/to the/directory/*

is equivalent to 2 separate rm -rf calls:

rm -rf /path/to
rm -rf the/directory/*

To avoid this issue, you can use 'single-quotes'(prevents all expansions, even of shell variables) or "double-quotes"(allows expansion of shell variables, but prevents other expansions):

rm -rf "/path/to the/directory/"*

Where:

  • rm - stands for remove
  • -f - stands for force which is helpful when you don't want to be asked/prompted if you want to remove an archive, for example.
  • -r - stands for recursive which means that you want to go recursively down every folder and remove everything.

To be updated more...

Load tab delimited data into a table:
LOAD DATA LOCAL INFILE 'C:/director/importdata.txt' INTO TABLE dbName.tableName FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';

select distinct(lang), (sum(textlength)) FROM dbName.tableName group by lang;


Count number of words in a field:
SELECT LENGTH(langtext) - LENGTH(REPLACE(langtext, ' ', ''))+1, id FROM dbName.tableName INTO OUTFILE "D:\\outdirector\\length.txt" limit 10;

गोस्वामी तुलसीदास रचित श्री रुद्राष्टकम् - शिव वंदना


नमामीशमीशान निर्वाणरूपं, विभुं व्यापकं ब्रह्मवेदस्वरूपम् ।
निजं निर्गुणं निर्विकल्पं निरीहं, चिदाकाशमाकाशवासं भजेऽहम् ॥ १॥

निराकारमोंकारमूलं तुरीयं, गिरा ज्ञान गोतीतमीशं गिरीशम् ।
करालं महाकाल कालं कृपालं, गुणागार संसारपारं नतोऽहम् ॥ २॥

तुषाराद्रि संकाश गौरं गभीरं, मनोभूत कोटिप्रभा श्री शरीरम् ।
स्फुरन्मौलि कल्लोलिनी चारु गङ्गा, लसद्भालबालेन्दु कण्ठे भुजङ्गा ॥ ३॥

These are some of excel formulas I use often.

1. The following to to find the unique case sensitive entries in a column:

=REPT($A2,SUMPRODUCT(--EXACT($A2,$A$1:$A1))=0)

2. Formula to count frequencey in excel given two columns, the first comprising of data and the other comprising of the values whose frequency is to be counted:
=COUNTIF(A1:A1085,B1:B340)

I recently started using OmegaT, a free software to translate internal projects that I have with me.

One issue that I find while translating text files is that it does not take the line marks as a segment breaker. This can be changed by going into Options -> File Filters and under "Text Files", select options to choose the "Line Breaks" as the segment source.