Показ дописів із міткою linux. Показати всі дописи
Показ дописів із міткою linux. Показати всі дописи

четвер, 5 вересня 2013 р.

Useful unix commands


1. Let's assume you have very long CSV file and you wish to find all non-empty columns #25, so:
tail -n +1 data.csv | cut -d ',' -f 25 | grep -v "^[[:space:]]*$"

2. In the previous file you need to find number of all rows with value 'CA' in the column 25:
cat -n data.csv | cut -d ',' -f 25,1 | grep -e "CA.*"

In output, you will get column value as well as row number
3. In the huge file you wish to get row #250007 in separate file:
sed -n '250007p' data.csv | cat > line_250007.csv

4. To get number of tabulation in line
tr -cd \t < line_250007.csv | wc -c

5. Ensure file copy is complete before starting process or ensure that file is not used by other process right now:
if [ $(lsof $file | wc -l) -gt 1 ] ; then
    echo "file $file still loading, skipping it"
else
    echo "file $file completed upload, process it"
fi

6. Color script output for better visualisation
NORMAL=$(tput sgr0)
GREEN=$(tput setaf 2; tput bold)
RED=$(tput setaf 1)

function red() {
    echo -e "$RED$*$NORMAL"
}

function green() {
    echo -e "$GREEN$*$NORMAL"
}

red "This is error message"

7. Find all files in directory by regexp:
for FILE in $(ls $DIR | grep ^report_.*csv$)
do
...
done

8. Check previous command result
mkdir -p $WRK_DIR
if [ $? -ne 0 ]; then
  #do something
fi

9. Extract 12 hours from NOW and cast to specific format:
date -d "+12 hours" +\%Y\%m\%d\%H

субота, 17 листопада 2012 р.

Fix microphone problem in Ubuntu

I'm using Ubuntu/Kubuntu on a Dell laptop, and it doesn't seem to recognize my headset's microphone. What can I do?

It was the question that was worried me for a last week. Actually, my microphone stopped working suddenly on the previous weekends. And my microphone didn't work in Skype nor Gtalk, it was awful!
I was looking for solution for a several hours and found it just a seconds ago! Hopefully  it was described here http://preprocess.me/skype-microphone-does-not-work-on-ubuntu-heres-a-fix for Ubuntu (Ideal works under Kubuntu too)

Just main steps (to me in the future):

  1. Run alsamixer
  2. Go to Capture devices
  3. Select capture device (I had two) and highlight it; then pres space to enable - you capture device must be highlighted in Red "Capture" label

вівторок, 26 липня 2011 р.

RabbitVCS - greate SVN client for Linux

Певно багато хто з користувачів SVN звик до приємної та зручної у використані черепашки TortoiseSVN. Яка її гарна альтернатива під Лінуксом? Моя найюлюбленіша (і цілком заслужено, насправді) є RabbitVCS - rabbitvcs.org - справді швидки та пухнастий кролик.
В Убунті ставить в кілька кроків:
1) додаємо новий репозиторій
sudo add-apt-repository ppa:rabbitvcs/ppa
і апдейтимо
sudo apt-get update
2) тепер стягуємо та інсталюємо кролика
sudo apt-get install rabbitvcs-core rabbitvcs-nautilus rabbitvcs-thunar rabbitvcs-gedit rabbitvcs-cli
3) перезапускаємо (точніше тут просто вбиваємо Наутілус (звісно, якщо ви використовуєте наутілус))
killall nautilus

Після перезапуска в наутілусі по правому кліку з"явить меню роботи з SVN, а файли під системою контроля версій матимуть характерну помітку, відображаючи їх статус