Archív značiek: command

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