Archive for the ‘Linux’ Category

Replacing Text in files using Perl

Wednesday, February 18th, 2009

perl -pi.bak -e “s/pattern/new_string/g” *

Using FFMPEG to extract or convert videos to Images

Friday, December 12th, 2008

The simple command to use to convert a given video video.ext to a set of images preferably with the naming format XXXX.png is :

ffmpeg -i video.ext %4d.png

It will produce images with the naming : 0001.png 0002.png and so on. You can try different image format if needed ( Jpeg, bmp…)

In case you want to extract and convert only a specific portion of the video :

ffmpeg -ss hh:mm:ss -t hh:mm:ss -i video.ext %4d.png
-ss option is the starting point whilst -t option is the duration to be converted.

selinux and HTTPD & svftps under CentOS

Tuesday, August 5th, 2008

to make httpd work and avoid the selinux headaches :

setsebool httpd_disable_trans 1
setsebool httpd_can_network_connect_db=1
service httpd restart

For the FTP server ( vsftpd )

setsebool -P ftpd_disable_trans 1
service vsftpd restart

How to print lines in a reverse order using awk

Friday, August 24th, 2007

Linux is the best! you will get all the tools to do the work efficiently! and for FREE!

Outputs lines from a file in reverse order using awk :

awk '{line[NR]= $0} END { for (i=NR; i >0;i--) print line[i] }' filename

How to trim strings using awk

Monday, August 20th, 2007

To trim space inside an awk inline script, the following command does the job:

awk -F"|" '{gsub(/ *$/,"",$1);gsub(/^ */,"",$1); print $1} - Imed Bouchrika Website© 2003-2007.