Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Wednesday, October 14, 2015

linux shell: how to run bash command with timeout

bash$     (date >> /tmp/bw.log ; vnstat -l -i bond0 &>> /tmp/bw.log) & sleep 5 ; kill $!

linux shell: paste komutu kullanımı

$ cat testfile
A 1
B 2
C 3
D 4
E 5
F 6
G 7
H 8
I 9
J 10
                                                                                                                                                                                                                                         $ cut -d' ' -f2 testfile
1
2
3
4
5
6
7
8
9
10
                                                                                                                                                                                                                                         $ cut -d' ' -f2 testfile | paste -d, - -
1,2
3,4
5,6
7,8
9,10


Keywords: how to parse and group lines, how to convert lines to columns, how to  convert rows to columns

Friday, March 6, 2015

bash call for disk usage tests

Aşağıdaki komut çağrısı 70 adet 1G büyüklüğünde dosya yaratacaktır. Disk doluluk test ortamı yaratmak için kullanılabilir.

linux-shell $ for i in {1..70}; do
         dd if=/dev/zero of=testfile.$i bs=1G count=1
         echo "testfile.$i created"
done

Tuesday, January 27, 2015

linux shell: comm komutu kullanımı hakkında

comm - compare two sorted files line by line
 
iki dosyayı satır satır kıyaslayarak yapabileceğiniz işlemler için kullanılır.
 
örn: file1 ve file2  de tekrar eden satırları görmek istediğimiz durum için:


 
VirtualBox:~$ cat file1
A
B
C
D
E
F
G
 
 
 
VirtualBox:~$ cat file2
C
E
X
Y
Z
 
olsun

  
### file1 ve file2'de tekrar eden satırlar
 
VirtualBox:~$ comm -12 file1 file2
C
E
 
 
 
 
### file1'de olup file2'de olmayan satırlar
 
VirtualBox:~$ comm -32 file1 file2
A
B
D
F
G
 
 
 



EXAMPLES
       comm -12 file1 file2
              Print only lines present in both file1 and file2.

       comm -3 file1 file2
              Print lines in file1 not in file2, and vice versa