Mayıs 8, 2014 § § Kalıcı bağlantı
İki txt dosyamız olduğunu düşünelim.
Bunlardaki her satırın tekilligini sağlamak için:
sort 1.txt| uniq -u >1.tekil.txt
yapılabilir.
Her satırı tekil olan 1.txt ve 2.txt dosyaları için
Küme birleşimi:
cat 1.txt 2.txt | sort -u
Küme farkı
cat 1.txt 2.txt 2.txt | sort -u
Küme kesişimi
cat 1.txt 2.txt | uniq -d
Mart 27, 2014 § § Kalıcı bağlantı
Herhangi bir değişiklik yapmadan önce dosyaların yedeğini almak için bu yöntem kullanılabilinir.
Önce küme işaretinin nasıl çalıştığını bir anlayalım.
Örneğin
[root@localhost ~]# echo {a,b,c}{a,b,c}{a,b,c}
aaa aab aac aba abb abc aca acb acc baa bab bac bba bbb bbc bca bcb bcc caa cab cac cba cbb cbc cca ccb ccc
[root@localhost ~]# echo {a,b,c}{a,b}
aa ab ba bb ca cb
[root@localhost ~]# echo {a,b,c}x
ax bx cx
[root@localhost ~]# echo {a,b,c}xy
axy bxy cxy
[root@localhost ~]# echo {a,b,c}x{1,2}
ax1 ax2 bx1 bx2 cx1 cx2
Görüldüğü üzere küme ile kartezyen çarpım yapılmaktadır.
Küme içinde boşluk karakteri de kullanılabilinir.
[root@localhost ~]# echo {a,b,c}{,1,2}
a a1 a2 b b1 b2 c c1 c2
Değiştirmeden önce dosyanın yedeğini almak için
root@localhost ~]# cp filename{,.bak}
veya degişim zamanını da backupa katmak için
root@localhost ~]# cp set.txt{,".$(date "+%Y%m%d%H%M%S")"}
[root@localhost ~]# ls set.txt*
set.txt set.txt.20140327134115
kullanılabilir.
Şubat 10, 2014 § § Kalıcı bağlantı
1- İmage, pdf veya videoda üst veri öğrenmek için exiftool kullanılabilir.
Önce kuralım:
[root@xxxx ~]# sudo yum install perl-Image-ExifTool
Loaded plugins: refresh-packagekit, security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package perl-Image-ExifTool.noarch 0:8.50-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
perl-Image-ExifTool noarch 8.50-1.el6 epel 2.2 M
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 2.2 M
Installed size: 9.2 M
Is this ok [y/N]: y
Downloading Packages:
perl-Image-ExifTool-8.50-1.el6.noarch.rpm | 2.2 MB 00:04
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-Image-ExifTool-8.50-1.el6.noarch 1/1
Verifying : perl-Image-ExifTool-8.50-1.el6.noarch 1/1
Installed:
perl-Image-ExifTool.noarch 0:8.50-1.el6
Complete!
Şimdi video üst verisine bakalım:
[root@xxxx ~]# exiftool sample_mpeg4.mp4
ExifTool Version Number : 8.50
File Name : sample_mpeg4.mp4
Directory : .
File Size : 240 kB
File Modification Date/Time : 2005:11:03 10:25:32-05:00
File Permissions : rw-r--r--
File Type : MP4
MIME Type : video/mp4
Major Brand : MP4 v2 [ISO 14496-14]
Minor Version : 0.0.1
Compatible Brands : mp42, mp41
Movie Header Version : 0
Create Date : 2005:10:28 17:46:46
Modify Date : 2005:10:28 17:46:46
Time Scale : 600
Duration : 4.97 s
Preferred Rate : 1
Preferred Volume : 100.00%
Preview Time : 0 s
Preview Duration : 0 s
Poster Time : 0 s
Selection Time : 0 s
Selection Duration : 0 s
Current Time : 0 s
Next Track ID : 3
Track Header Version : 0
Track Create Date : 2005:10:28 17:46:46
Track Modify Date : 2005:10:28 17:46:46
Track ID : 1
Track Duration : 4.97 s
Track Layer : 0
Track Volume : 100.00%
Balance : 0
Audio Format : mp4a
Audio Channels : 2
Audio Bits Per Sample : 16
Audio Sample Rate : 32000
Matrix Structure : 1 0 0 0 1 0 0 0 1
Image Width : 190
Image Height : 240
Media Header Version : 0
Media Create Date : 2005:10:28 17:46:46
Media Modify Date : 2005:10:28 17:46:46
Media Time Scale : 30
Media Duration : 4.97 s
Media Language Code : eng
Handler Type : Video Track
Handler Description : Apple Video Media Handler
Graphics Mode : srcCopy
Op Color : 0 0 0
Compressor ID : mp4v
Source Image Width : 190
Source Image Height : 240
X Resolution : 72
Y Resolution : 72
Bit Depth : 24
Video Frame Rate : 30
Movie Data Size : 242685
Avg Bitrate : 391 kbps
Image Size : 190x240
Rotation : 0
2.tovid kullanabiliriz.
Önce kuralım:
$ aria2c http://tovid.googlecode.com/files/tovid-0.34.tar.gz
$ cd ~/Downloads
$ tar -xzvf tovid-0.34.tar.gz
$ cd tovid-0.34
$ ./setup.py build
$ su -c './setup.py uninstall'
Şimdi videonun özelliklerine bakalım:
[root@xxx ~]# tovid sample_mpeg4.mp4
Usage:
tovid [command] [arguments ...]
Where 'command' is one of the following:
Command Description Formerly
-----------------------------------------------------------------
id Identify one or more video files idvid
dvd Author and/or burn a DVD makedvd
menu Create an MPEG menu makemenu
vcd Author and/or burn a VCD makevcd
xml Create (S)VCD or DVD .xml file makexml
postproc Post-process an MPEG video file postproc
disc Create a DVD with menus todisc
gui Start the tovid GUI todiscgui
mpg Encode videos to MPEG format tovid
titlesets Start the titleset wizard (new)
chapters Set video chapter points with mplayer (new)
The following general options are also available:
--prefix | -prefix Return the tovid install prefix
--version | -version Return the tovid version
--info | -info Return prefix, version and python module search path
These options are to be used on their own, as in: tovid --prefix
Run 'tovid <command>' with no further arguments to get help on a command,
and what arguments it expects.
Unknown command: 'sample_mpeg4.mp4'
[root@xxx ~]# tovid id sample_mpeg4.mp4
Read options from /root/.tovid/tovid.ini:
=========================================================
mplex MISSING!
=========================================================
mpeg2enc MISSING!
=========================================================
yuvfps MISSING!
=========================================================
yuvdenoise MISSING!
=========================================================
ppmtoy4m MISSING!
=========================================================
mp2enc MISSING!
=========================================================
jpeg2yuv MISSING!
You are missing CORE tovid dependencies! Please install the above MISSING
dependencies and try again. See tovid.wikia.com/wiki/Tovid_dependencies for
help.
=========================================================
Kayıp paketler olduğu aşikar. Bu sorunu aşabilmek için mjpegtools paketini kuralım:
[root@xxx ~]# yum install mjpegtools
Loaded plugins: refresh-packagekit, security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mjpegtools.x86_64 1:2.0.0-22.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mjpegtools x86_64 1:2.0.0-22.el6 atrpms 734 k
Transaction Summary
================================================================================
Install 1 Package(s)
Total download size: 734 k
Installed size: 2.2 M
Is this ok [y/N]: y
Downloading Packages:
mjpegtools-2.0.0-22.el6.x86_64.rpm | 734 kB 00:03
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 1:mjpegtools-2.0.0-22.el6.x86_64 1/1
Verifying : 1:mjpegtools-2.0.0-22.el6.x86_64 1/1
Installed:
mjpegtools.x86_64 1:2.0.0-22.el6
Complete!
Şimdi video özelliklerine bakalım:
[root@xxx ~]# tovid id /home/fatih/sample_mpeg4.mp4
Read options from /root/.tovid/tovid.ini:
--------------------------------
tovid id
Identify video files
Version 0.34
http://tovid.wikia.com
--------------------------------
Could not find file: /home/fatih/sample_mpeg4.mp4
[root@xxx ~]# tovid id /home/fatih/small.mp4
Read options from /root/.tovid/tovid.ini:
--------------------------------
tovid id
Identify video files
Version 0.34
http://tovid.wikia.com
--------------------------------
Analyzing file: '/home/fatih/small.mp4'...
=========================================================
File: /home/fatih/small.mp4
Width: 560 pixels
Height: 320 pixels
Aspect ratio: 1.75:1
Frames: 0
Duration: 00:00:05 hours/mins/secs
Framerate: 30.000 frames per second
Video format: H264
Video bitrate: 465640 bits per second
---------------------------
Audio track 1 (Stream Stream, AID 0):
---------------------------
Codec:
Bitrate: 83048000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 2 (Stream #0:1(eng):, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 3 (Stream Audio:, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 4 (Stream aac, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 5 (Stream (mp4a, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 6 (Stream /, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 7 (Stream 0x6134706D),, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 8 (Stream 48000, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 9 (Stream Hz,, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 10 (Stream mono,, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 11 (Stream fltp,, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 12 (Stream 83, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
---------------------------
Audio track 13 (Stream kb/s, AID ):
---------------------------
Codec:
Bitrate: 0000 bits per second
Sampling rate: ? Hz
=========================================================
Audio is compliant with the following formats:
Not compliant with (S)VCD or DVD
Video is compliant with the following formats:
Not compliant with (S)VCD or DVD
This video does not seem to be compliant with (S)VCD or DVD
standards. If you burn it to a video disc, it may not work.
=========================================================
Not:exiftool hata yapabilir. Zira exif bilgilerini okuyor. Fakat tovid dosyanın içine bakıyor. Hata yapma ihtimali azdır.
3. mplayer kullanmak
[fatih@xxx ~]$ mplayer -vo null -ao null -identify -frames 0 H264_test1_Talkinghead_mp4_480x360.mp4
MPlayer SVN-r36251-snapshot-4.4.6 (C) 2000-2013 MPlayer Team
Can't open joystick device /dev/input/js0: No such file or directory
Can't init input joystick
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing H264_test1_Talkinghead_mp4_480x360.mp4.
libavformat version 55.4.101 (internal)
libavformat file format detected.
ID_AUDIO_ID=0
ID_AID_0_LANG=eng
[lavf] stream 0: audio (aac), -aid 0, -alang eng
ID_VIDEO_ID=0
[lavf] stream 1: video (h264), -vid 0
VIDEO: [H264] 480x360 24bpp 24.000 fps 206.7 kbps (25.2 kbyte/s)
Clip info:
major_brand: mp42
ID_CLIP_INFO_NAME0=major_brand
ID_CLIP_INFO_VALUE0=mp42
minor_version: 1
ID_CLIP_INFO_NAME1=minor_version
ID_CLIP_INFO_VALUE1=1
compatible_brands: mp42avc1
ID_CLIP_INFO_NAME2=compatible_brands
ID_CLIP_INFO_VALUE2=mp42avc1
creation_time: 2009-02-26 21:49:46
ID_CLIP_INFO_NAME3=creation_time
ID_CLIP_INFO_VALUE3=2009-02-26 21:49:46
ID_CLIP_INFO_N=4
Load subtitles in ./
ID_FILENAME=H264_test1_Talkinghead_mp4_480x360.mp4
ID_DEMUXER=lavfpref
ID_VIDEO_FORMAT=H264
ID_VIDEO_BITRATE=206704
ID_VIDEO_WIDTH=480
ID_VIDEO_HEIGHT=360
ID_VIDEO_FPS=24.000
ID_VIDEO_ASPECT=0.0000
ID_AUDIO_FORMAT=MP4A
ID_AUDIO_BITRATE=85056
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=2
ID_START_TIME=0.00
ID_LENGTH=14.97
ID_SEEKABLE=1
ID_CHAPTERS=0
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 55.7.100 (internal)
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
ID_VIDEO_CODEC=ffh264
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, floatle, 85.1 kbit/3.01% (ratio: 10632->352800)
ID_AUDIO_BITRATE=85056
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=2
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
AO: [null] 44100Hz 2ch floatle (4 bytes per sample)
ID_AUDIO_CODEC=ffaac
Starting playback...
Exiting... (End of file)
ID_EXIT=EOF
4. ffmpeg kullanmak
[fatih@xxx ~]$ ffmpeg -i H264_test1_Talkinghead_mp4_480x360.mp4
ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
built on May 10 2013 15:14:14 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping
libavutil 52. 18.100 / 52. 18.100
libavcodec 54. 92.100 / 54. 92.100
libavformat 54. 63.104 / 54. 63.104
libavdevice 54. 3.103 / 54. 3.103
libavfilter 3. 42.103 / 3. 42.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'H264_test1_Talkinghead_mp4_480x360.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp42avc1
creation_time : 2009-02-26 21:49:46
Duration: 00:00:14.98, start: 0.000000, bitrate: 600 kb/s
Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 85 kb/s
Metadata:
creation_time : 2009-02-26 21:49:46
handler_name : Apple Sound Media Handler
Stream #0:1(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 480x360, 206 kb/s, 24 fps, 24 tbr, 600 tbn, 1200 tbc
Metadata:
creation_time : 2009-02-26 21:49:46
handler_name : Apple Video Media Handler
Stream #0:2(eng): Data: none (rtp / 0x20707472), 212 kb/s
Metadata:
creation_time : 2009-02-26 21:49:46
handler_name : hint media handler
Stream #0:3(eng): Data: none (rtp / 0x20707472), 88 kb/s
Metadata:
creation_time : 2009-02-26 21:49:46
handler_name : hint media handler
At least one output file must be specified
[fatih@xxx ~]$
Kişisel favorim mplayer.
Şubat 10, 2014 § § Kalıcı bağlantı
livestreamer kuralım:
$ sudo yum install python-pip
$ sudo pip install livestreamer
livestreamer ile Youtube izlemek için
livestreamer http://www.youtube.com/watch?v=U4Pw3ofFWgs best
veya
livestreamer --player=mplayer http://www.youtube.com/watch?v=U4Pw3ofFWgs 360p
Şubat 10, 2014 § § Kalıcı bağlantı
Önce grep dosru sonuç veriyor mu kontrol edelim:
ps aux | grep jppf
xmodulo 3324 0.1 2.9 156524 15176 pts/0 Sl 22:16 0:01 /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/bin/java -Xmx32m -Djppf.config=jppf-driver.properties -Dlog4j.configuration=log4j-driver.properties -Djava.util.logging.config.file=config/logging-driver.properties -classpath /home/xmodulo/JPPF-3.2.2-driver/config:/home/xmodulo/JPPF-3.2.2-driver/lib/jmxremote_optional.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/jppf-common-node.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/jppf-common.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/jppf-server.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/log4j-1.2.15.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/slf4j-api-1.6.1.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/slf4j-log4j12-1.6.1.jar org.jppf.server.DriverLauncher
xmodulo 3338 0.3 4.4 391484 22792 pts/0 Sl 22:16 0:03 /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/bin/java -cp /home/xmodulo/JPPF-3.2.2-driver/config:/home/xmodulo/JPPF-3.2.2-driver/lib/jmxremote_optional.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/jppf-common-node.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/jppf-common.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/jppf-server.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/log4j-1.2.15.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/slf4j-api-1.6.1.jar:/home/xmodulo/JPPF-3.2.2-driver/lib/slf4j-log4j12-1.6.1.jar -Djppf.config=jppf-driver.properties -Dlog4j.configuration=log4j-driver.properties -Xmx256m -Djava.util.logging.config.file=config/logging-driver.properties org.jppf.server.JPPFDriver 59216
xmodulo 3388 0.1 2.9 139144 15064 pts/0 Sl 22:19 0:01 /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/bin/java -Xmx16m -Dlog4j.configuration=log4j-node.properties -Djppf.config=jppf-node.properties -Djava.util.logging.config.file=config/logging-node.properties -classpath /home/xmodulo/JPPF-3.2.2-node/config:/home/xmodulo/JPPF-3.2.2-node/lib/jmxremote_optional.jar:/home/xmodulo/JPPF-3.2.2-node/lib/jppf-common-node.jar:/home/xmodulo/JPPF-3.2.2-node/lib/log4j-1.2.15.jar:/home/xmodulo/JPPF-3.2.2-node/lib/slf4j-api-1.6.1.jar:/home/xmodulo/JPPF-3.2.2-node/lib/slf4j-log4j12-1.6.1.jar org.jppf.node.NodeLauncher
xmodulo 3402 0.1 3.9 257980 20288 pts/0 Sl 22:19 0:01 /usr/lib/jvm/java-1.6.0-
Birçok processi grep ile ayıklayıp öldürmek için:
kill -9 `ps aux | grep <keyword> | awk '{print $2}'`
Şubat 10, 2014 § § Kalıcı bağlantı
now=$(date +"%Y-%m-%d-%S")
filename="my_program.$now.log"
# example filename: my_program.2012-01-23-47.log
nanosecond seviyesinde zaman için:
now=$(date +"%Y.%m.%d.%S.%N")
filename="my_program.$now.log"
# example filename: my_program.2013.01.23.44.364617000.log
epoch olarak zaman:
now=$(date +"%s")
filename="my_program.$now.log"
# example filename: my_program.1358995092.log
Ocak 15, 2014 § § Kalıcı bağlantı
rsync komutunun -a parametresi ile kullanımı bu iş için uygun görünüyor.
Not1: -a kullanılmadığında izinler korunmamaktadir.
Not2: -a kullanıldığında recursive için -r’ye ihtiyaç yoktur. -a zaten recursivedir.
Genel olarak parametreler:
-v : verbose
-r : recursive copyalama sağlar fakat izinler korunmaz
-a : arşiv modu. Recursive çalışır ve izinleri, sahiplikleri vs korur
-z : dosyaları sıkıştırarak gönderir
-h : human-readable formatta çıktı verir
Örnek:
[root@fatihoz ~]# rsync -azvh --progress /home/fatih/1G.file /tmp/
sending incremental file list
1G.file
1.02G 100% 38.46MB/s 0:00:25 (xfer#1, to-check=0/1)
sent 995.86K bytes received 31 bytes 33.76K bytes/sec
total size is 1.02G speedup is 1028.22
[root@fatihoz ~]# ls -l /tmp/1G.file
-rw-rw-r--. 1 fatih fatih 1024000000 Jan 15 05:59 /tmp/1G.file
Not3:recursive kopyalama da eğer dizinide kopyalamak istiyorsak dizin adından sonra “/” konmamalıdır.
Dizin içeriğini taşımak için:
[root@fatihoz ~]# rsync -azvh --progress deneme/ /tmp/
sending incremental file list
./
1.txt
0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=3/5)
12233434543.txt
0 100% 0.00kB/s 0:00:00 (xfer#2, to-check=2/5)
122343.txt
0 100% 0.00kB/s 0:00:00 (xfer#3, to-check=1/5)
123.txt
0 100% 0.00kB/s 0:00:00 (xfer#4, to-check=0/5)
sent 246 bytes received 91 bytes 674.00 bytes/sec
total size is 0 speedup is 0.00
[root@fatihoz ~]# ls /tmp/
12233434543.txt .ICE-unix/ .vbox-root-ipc/
122343.txt keyring-laEwp7/ virtual-fatih.1zDlF2/
123.txt orbit-fatih/ virtual-fatih.VRdNGR/
1G.file orbit-gdm/ virtual-fatih.XuZfls/
1.txt pulse-Z1C3D8mISpLD/ .X0-lock
.esd-500/ .vbox-fatih-ipc/ .X11-unix/
Dizini de taşımak için
[root@fatihoz ~]# rsync -azvh --progress deneme /tmp/
sending incremental file list
deneme/
deneme/1.txt
0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=3/5)
deneme/12233434543.txt
0 100% 0.00kB/s 0:00:00 (xfer#2, to-check=2/5)
deneme/122343.txt
0 100% 0.00kB/s 0:00:00 (xfer#3, to-check=1/5)
deneme/123.txt
0 100% 0.00kB/s 0:00:00 (xfer#4, to-check=0/5)
sent 261 bytes received 92 bytes 706.00 bytes/sec
total size is 0 speedup is 0.00
[root@fatihoz ~]# ls /tmp/deneme/
12233434543.txt 122343.txt 123.txt 1.txt
Uzakdaki bilgisayara dosya göndermek için:
[root@fatihoz ~]# rsync -avh --progress /home/fatih/1G.file root@localhost:/tmp/
The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is a8:6a:b1:43:9b:33:e4:78:cc:d0:ee:9d:e0:c2:0e:fe.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
root@localhost's password:
sending incremental file list
1G.file
1.02G 100% 23.49MB/s 0:00:41 (xfer#1, to-check=0/1)
sent 1.02G bytes received 31 bytes 21.12M bytes/sec
total size is 1.02G speedup is 1.00
Ocak 2, 2014 § § Kalıcı bağlantı
“{}” veya “-I” ya girilen parametre
[fatih@fatihoz deneme]$ find . -iname "*.txt" -print0 | xargs -0 -I {} cat {}
veya
[fatih@fatihoz deneme]$ find . -iname "*.txt" -print0 | xargs -0 -I match_file mv match_file ./yeni_klasor/
[fatih@fatihoz deneme]$ ls -laR
.:
total 12
drwxrwxr-x. 3 fatih fatih 4096 Jan 2 06:58 .
drwx------. 46 fatih fatih 4096 Jan 2 06:42 ..
drwxrwxr-x. 2 fatih fatih 4096 Jan 2 06:58 yeni_klasor
./yeni_klasor:
total 24
drwxrwxr-x. 2 fatih fatih 4096 Jan 2 06:58 .
drwxrwxr-x. 3 fatih fatih 4096 Jan 2 06:58 ..
-rw-rw-r--. 1 fatih fatih 13 Jan 2 06:42 112.txt
-rw-rw-r--. 1 fatih fatih 18 Jan 2 06:42 1345.txt
-rw-rw-r--. 1 fatih fatih 25 Jan 2 06:42 1.txt
-rw-rw-r--. 1 fatih fatih 29 Jan 2 06:42 456.txt
Ocak 2, 2014 § § Kalıcı bağlantı
Boşluk karakteri içeren dosya isimlerini yakalayabilmek için
find’da “-print0”, xargs’de “-0” parametreleri kullanılmalıdır.
[fatih@fatihoz deneme]$ ls -la
total 12
drwxrwxr-x. 2 fatih fatih 4096 Jan 2 06:25 .
drwx------. 46 fatih fatih 4096 Jan 2 06:13 ..
-rw-rw-r--. 1 fatih fatih 0 Jan 2 06:25 123123123.txt
-rw-rw-r--. 1 fatih fatih 0 Jan 2 06:25 123.txt
-rw-rw-r--. 1 fatih fatih 9 Jan 2 06:11 ali veli.txt
-rw-rw-r--. 1 fatih fatih 0 Jan 2 06:25 asdasd.txt
find "print" ile boşluk karakterli dosyaları yakalasa da çalışmaya olanak vermiyor
[fatih@fatihoz deneme]$ find . -name "*.txt" -print| cat
./ali veli.txt
./123.txt
./asdasd.txt
./123123123.txt
[fatih@fatihoz deneme]$ find . -name "*.txt" -print| xargs cat
cat: ./ali: No such file or directory
cat: veli.txt: No such file or directory
[fatih@fatihoz deneme]$ find . -name "*.txt" -print| xargs rm -rf
[fatih@fatihoz deneme]$ ls -la
total 12
drwxrwxr-x. 2 fatih fatih 4096 Jan 2 06:28 .
drwx------. 46 fatih fatih 4096 Jan 2 06:13 ..
-rw-rw-r--. 1 fatih fatih 9 Jan 2 06:11 ali veli.txt
Doğru kullanımı:
[fatih@fatihoz deneme]$ find . -name "*.txt" -print0 | xargs -0 rm -rf
[fatih@fatihoz deneme]$ ls
[fatih@fatihoz deneme]$
-print0’ın açıklamasi
”
-print0
True; print the full file name on the standard output, followed by a null character (instead of
the newline character that -print uses). This allows file names that contain newlines or other
types of white space to be correctly interpreted by programs that process the find output. This
option corresponds to the -0 option of xargs.
”
Ocak 2, 2014 § § Kalıcı bağlantı
Xargs stdin’den input alıp bunu stdout’a echo ile basar.
ctrl-d ile stdout’a sonuc basılabilir.
xargs komutunun newline karakterlerini gözardı etmesine dikkat edelim.
[fatih@fatihoz ~]$ xargs
deneme1
deneme2
yeni satır1
deneme1 deneme2 yeni satır1
“-t” parametresi ile xargs’in echo çağırdığı görülebilir:
[fatih@fatihoz ~]$ xargs -t
deneme satırı
/bin/echo deneme satırı
deneme satırı
find ile xargs kullanımı
find ile bulduğumuz dosya isimlerini xargs’e input girip echo dışında iş yürütebiliriz.
Örn:
xargs’nin stdinden input alması ile ilgili bir diğer örnek:
[fatih@fatihoz ~]$ echo a b c d e | xargs
a b c d e
xargs’nin stdout’a bastığı çıktının bir satırda kaç adet olacağı “-n” parametresi ile verilebilir:
[fatih@fatihoz ~]$ echo 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | xargs -n 3
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17
[fatih@fatihoz ~]$ echo 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | xargs -n 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17
“-p” parametresi ile kullanicinin doğrulaması sağlanabilir:
[fatih@fatihoz ~]$ echo 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | xargs -p -n 4
/bin/echo 1 2 3 4 ?...y
/bin/echo 5 6 7 8 ?...1 2 3 4
y
/bin/echo 9 10 11 12 ?...5 6 7 8
y
/bin/echo 13 14 15 16 ?...9 10 11 12
y
/bin/echo 17 ?...13 14 15 16
y
17
find ile bulduğumuz dosya isimlerini xargs’ye sokabiliriz
Örn:
Dosya içeriklerine bakalım
[fatih@fatihoz deneme]$ grep . *
1.txt:Birinci dosyanin baslangici
1.txt:123123123123 123 12 3 12 31 23 1 2312 3 123
1.txt:123
1.txt:12
1.txt:3
1.txt:12
1.txt:3
1.txt:12312312432454
1.txt:5
1.txt:3
1.txt:45
1.txt:34
1.txt:5
2.txt:İkinci dosyanin baslangici
2.txt:12312 5345 anan3 12312345
2.txt:34
2.txt:5
txt dosyalarda "dosyanin" metnini arayalim
[fatih@fatihoz deneme]$ find . -name "*.txt"| xargs grep "dosyanin"
./2.txt:İkinci dosyanin baslangici
./1.txt:Birinci dosyanin baslangici
txt dosyalarini silelim
[fatih@fatihoz deneme]$ find . -name "*.txt"| xargs rm -rf