Tuesday, April 9, 2013

Count the occurrences of a string per line in a file


cat exampleFile
text 1 text
text text 4 text 56
2
4
test
345
87 text

Count the occurrences of 'text' in exampleFile per line
awk -F "text" '{print NF-1}' exampleFile
2
3
0
0
0
0
1

Friday, March 29, 2013

Sort,uniq (string, int) columns in csv files


cat file

text1,5
text4,3
text3,1
text1,4
text7,2
text3,7
text2,9


1. less file | sort -u -t, -k1,1 - sort the first column and get unique texts
text1,5
text2,9
text3,1
text4,3
text7,2

2. less file | sort -u -t, -k1,1 | sort -t, -k2 -nr - get unique texts on first column and reverse order for the second column using -r option
text2,9
text1,5
text4,3
text7,2
text3,1

Saturday, September 15, 2012

Grep in pdf file for a certain word

find . -name '*.pdf' -exec pdftotext {} - \; | grep -rn "test"

find . -name "*.pdf" -print0| while read -d $'' file; do co=$(pdftotext -q "$file" - |grep -crn "test"); if [ $co -ne 0 ]; then echo $co - "$file" ; fi ; done

Wednesday, September 12, 2012

uninstall a firefox plugin

http://askubuntu.com/questions/150095/how-to-uninstall-a-firefox-plugin


Manually uninstalling a plugin

If you can't use an uninstaller program to remove a plugin, you can remove it manually:

In the Location bar, type about:config and press Enter.

The about:config "This might void your warranty!" warning page may appear. Click I'll be careful, I promise!, to continue to the about:config page.
Search for the preference: plugin.expose_full_path.

Double-click on the plugin.expose_full_path preference in the list to change the value to true.

Enter about:plugins into the Location bar to display the About Plugins page.

Each entry in the About Plugins page will have "File name:" followed by a path. Use Windows Explorer to navigateNavigate to the folder shown for the plugin you want to remove.

Rename the file to something other than its normal name - e.g. npswf32 becomes Xnpswf32

Double-click on the plugin.expose_full_path preference in the list on the about:config page to change the value back to false to avoid exposing the plugin path to websites.

Tuesday, September 11, 2012

Download a web site using wget

wget -r --level=0 -convert-links --page-requisites --no-parent <URL>
httrack <URL>

Thursday, August 9, 2012

download youtube files with youtube-dl-tci

curl -s "http://www.youtube.com/playlist?list=UUuqxLlNgdBCqhTxphhhTbZg&page=2" | grep watch? |cut -d\= -f3 | cut -d\& -f1 | grep -v data | grep -v watch | while read file ; do youtube-dl -tci "http://www.youtube.com/watch?v=$file" ; done

Wednesday, August 8, 2012

Install μTorrent in Ubuntu

wget http://download.utorrent.com/linux/utorrent-server-3.0-25053.tar.gz
sudo cp utorrent-server-3.0-25053.tar.gz /opt/
cd /opt/
sudo tar -xvf utorrent-server-3.0-25053.tar.gz
sudo rm -rf utorrent-server-3.0-25053.tar.gz
sudo chmod 777 -R utorrent-server-v3_0/
sudo ln -s /opt/utorrent-server-v3_0/utserver /usr/bin/utserver

Create a launcher in panel. In name field type utorrent and in command filed type 'utserver -settingspath /opt/utorrent-server-v3_0/ &'


Go to localhost:8080/gui and for user name type admin and password leave it empty.

Start launch application in Ubuntu 12.04 Unity

sudo apt-get install gnome-panel
gnome-desktop-item-edit --create-new ~/Desktop

Sunday, August 5, 2012

Read text with voice in Ubuntu

espeak --stdout -f text.txt | aplay -> read with voice file text.txt
espeak -v en-uk --stdout 'some text' | aplay -> read with voice some text
espeak --voices -> display all available voices