Thursday, March 20, 2008

Console

Теперь разделены статьи консоль и консоль для интернета

Как правильно спросить в никсах исполнимый файл или нет?
ls -l file1
или
stat -c %a file1

как скопировать пермишен одного файла другому?
chmod --reference=file1 file2

Прикольная команда делает список файлов с числовым представлением пермишенов
for i in $(ls) ; do bla=$( stat -c “%a” $i);echo “$i: $bla”; done

Замена одной папку в пути на другую
pwd | sed 's/\/старая_папка\//\/новая_папка\//'

Create tar gz archive
tar -pczf name_of_archive.tar.gz /path/to/directory

Bash Guide for Beginners
http://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html

Advanced Bash-Scripting Guide
http://tldp.org/LDP/abs/html/

Print dir with sort.
Сортировка папок по размеру
du -sb * | sort -n -t\ | more
thx Vitaliy

Print current dir
pwd | awk '{i=split($0, Name, "/") ; print ("Name[" i "]=" Name[i])}'
http://project.net.ru/web-master/unix_shell/article4/

List of directories
Список директорий
find . /* -type d -maxdepth 0
tree -dR -L 3

Make CD fs and burn it
mkisofs -r -o image.iso ivana_kupala/
sudo mkdir /mnt/iso
sudo mount -t iso9660 image.iso /mnt/iso -o loop
sudo umount /mnt/iso/
cdrecord -v -eject -dummy image.iso
cdrecord -v -eject image.iso


Make DVD
mkisofs -dvd-video -o /home/alexey/Download/karaoke.iso /home/alexey/Download/Karaoke/

isoinfo -i karaoke.iso-l

  1. Make an "ISO" filesystem image of a DVD filesystem:

    mkisofs -dvd-video dvd >dvd.iso

    dvd is the directory containing the filesystem produced by dvdauthor.

  2. Record "ISO" filesystem image to disc:

    growisofs -dvd-compat -Z /dev/dvd=dvd.iso

    The -Z option selects one-time recording or overwriting. growisofs can also record a new session (hence its name) but DVD videos must be recorded in a single session. The -dvd-compat option enables various recording features to improve compatibility.

  3. Record DVD filesystem directly to disc:

    growisofs -dvd-compat -Z /dev/dvd -dvd-video dvd
How to create ISO images from your HD CD DVD
=============================================
To make an ISO from your CD/DVD, place the media in your drive but do not mount it. If it automounts, unmount it. (ubuntu automount so you need to unmount, that's quite easy, just choose the option unmount from the shell).

dd if=/dev/dvd of=dvd.iso # for dvd
dd if=/dev/cdrom of=cd.iso # for cdrom
dd if=/dev/scd0 of=cd.iso # if cdrom is scsi

To make an ISO from files on your hard drive, create a directory which holds the files you want. Then use the mkisofs command.

mkisofs -o /tmp/cd.iso /tmp/directory/

This results in a file called cd.iso in folder /tmp which contains all the files and directories in /tmp/directory/.

=============================================


http://womble.decadent.org.uk/talks/dvd-ukuug06/dvd-talk-ukuug06-paper.html

Rename
Переименование последовательности символов в файлах
how-to-bulk-rename-files-in-linux-in-the-terminal
ex.
rename 's/(-2\.0-)/_v2_/' *


Count lines with find and wc
Как узнать количество строк во всех файлах ".java"
find . -wholename './*.java' -type f | xargs wc -l


Count directorys sizes with find and du
Как узнать обьем всех по отдельности папок в текущем каталоге
find . -maxdepth 1 -type d | xargs du -sh
du -h --max-depth 1

3 comments:

Anonymous said...

Hello. This post is likeable, and your blog is very interesting, congratulations :-). I will add in my blogroll =). If possible gives a last there on my blog, it is about the OLED, I hope you enjoy. The address is http://oled-brasil.blogspot.com. A hug.

Alexey Zavizionov said...

Updated:
Print current dir
pwd | awk '{i=split($0, Name, "/") ; print ("Name[" i "]=" Name[i])}'

Alexey Zavizionov said...

Упрощенной решение, позволяющее получить имя текущей папки:

pwd | awk '{print ("Dir is = " Name[split($0, Name, "/")])}'