Various helpful commands in unix/linux

MP3 to WAV using ‘mplayer’:

for i in *.mp3; do mplayer -ao pcm:file="${i}.wav" "$i" ; done

Computer timed Shutdown

shuts down in a hour:
sudo shutdown -Ph +60
cancel shutdown
sudo shutdown -c

Create thumbnails from images using ‘convert’

mkdir thumbs
for file in `ls -1 * 2>/dev/null`
do
   echo $file
   convert $file -resize 25% thumbs/$file
done

2009-10-24 13:52:41
Various kinds of loop on files in directory

for file in <directory>/*
do
   echo $file
   mv -f $file <another dir>
done

The is a problem with this for loop : if the directory is empty body of the loop is executed nevertheless with the variable file set to ‘<directory>/*’

Another solution with the for loop :
Code:

for file in `ls -1 <directory>/* 2>/dev/null’
do
   echo $file
   mv -f $file <another dir>
done

You can also use a while loop :
Code:

ls -1 <directory>/* 2>/dev/null |
while read file
   echo $file
   mv -f $file <another dir>
done

2009-10-24 21:19:37
Samba – mount remote dir

K krusaderovi napisat do prikazoveho riadku:

smb://192.168.1.150
vypyta si login / pwd – zadaj uzivatela s heslom

hotovo.

Ciel bude napr:  smb://share@192.168.1.150/mash

2009-11-04 22:00:15
Get audio track from movie

mplayer -vc null -vo null -ao pcm:fast source.avi

put audio track back into the movie:

mencoder source.avi -o destination.avi -ovc copy -audiofile noveaudio.mpeg2 -oac copy

Change movie audio track codec from AC to MPEG:

mencoder source.avi -o destination.avi -ovc copy -oac mp3lame

list of supported audio codecs:
mencoder -oac help


2010-10-05 22:36:42
WGET

skus cez wget, do shellu hod: wget –save-cookies=./kolace "https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi" -O /dev/null
–post-data="login=krasko&password=123456" so svojim loginom a heslom.
Nasledne sa ti vytvori subor kolace, potom si sprav subor zoznam do ktoreho si nakoporuj linky a spustis to takto: wget –load-cookies=./kolace -c -i zoznam .
A tot vse 😉

ja pouzivam command-line ‘wget’, ten vie so spravnymi prepinacmi spravit jednoducho pekny komplet mirror webstranky.

wget -m -l 1 -k -c "http://stranka"
-m : mirror (shortcut for -N -r -l inf –no-remove-listing.)
-l : max depth level 1
-k : convert links to local
-c : continue if you broken download


2010-12-01 10:07:14
How to find unix distribution

works mostly:
uname-a
output:
CYGWIN_NT-5.1 <pc_name> 1.7.5(0.225/5/3) 2010-04-12 19:07 i686 Cygwin

if not then try:
lsb_release -a
output:
LSB Version:    :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 5.4 (Tikanga)
Release:        5.4
Codename:       Tikanga

or try:
cat /etc/issue
output:
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
Kernel r on an m

How to setup project in KDevelop

novy projekt:

zalozka vpravo – Automake manager
 – v hornej casti klikni na ikonku ‘add new subproject’ a zadaj jeho meno, napriklad ‘src’. Bez subprojektu by sa linky
    na cpp subory pridavali priamo do projektoveho adresara. Takto budu pridavane do podadresara ‘src’
 – v hornej casti vyber projekt ‘src’ a klikni na ikonku ‘add target’ a zadaj meno cieloveho executable
 – v dolnej casti sa zobrazi <meno exe>( Program in bin ), okrem povodneho (header in noinst) (ale ten tam nebude kedze sme v podprojekte)
 – cpp ktore pridas do tohoto noveho itemu sa budu kompilovat
 – v menu / Project /  Project Options nastav Configure Options pre tvoj config, pravdepodobne ‘debug’. Do C/C++
    preprocessor daj cesty ku libkam, do Linker flags daj libky. V zalozke C++ mozes pridat definy,
    napr "-O0 -g3 -D_UNIX -D_DEBUG"
    Tieto nastavenia netreba nastavovat v Automake manageri cez ikonku kluca. Netreba tam nic vyplnat, vsetko
    sa nastavuje v Project options.
 – spusti Build / run Automake & friends
 – spusti Build / run Config
 – spusti Build / Build project
 – po kompilacii nastav v zalozke Run options nastav parametre pre spustanie. Napriklad
    executable: /home/mirex/work/biturn_svn/BiturnGtkmmKdev/debug
    Debug arguments: 002131080.C3 002131080.lwo -log 3 –general-owauto 1
    Working directory: /home/mirex/work/biturn_svn/BiturnGtkmmKdev/debug/src

2010-02-12 23:43:44
Error: "collect2: ld returned 1 exit status"
Can mean: you don’t have disk space left for linking the library.