Categories

Bash script for changing file extension

Bash script for changing extension type on many files inside the directory (for example, if you have many pictures ending in .jpeg and you want to change them to .gif):

#!/bin/bash

echo "source extension?" read source

echo "destination extension?" read target

for i in `ls *$source`; do

file=`ls $i | sed "s/$source/$target/"`

echo "changing source [...]

NERDTree vim plugin

Very useful thing if you want to extend your usage of VIM (which is, by my opinion, best editor in the world )

Basically it is acting as plugin to vim, after you run vim just type “:NERDTree” and see the magic – it will open tree with all files and directories from location where [...]

ALA – Apache log analyzer

Here is one simple bash script which can be used to quickly sort out which IP`s are most visiting your Apache web server, by analyzing access_log file.

You just put chmod +x on it and run as root … It will ask you for location of Apache log file, and after that you will get [...]

Another FTP backup script

The script will compress all files under /var/vmail with tar using “Z” flag and send that tar.tgz file to remote FTP server. It will remove previous backup file, and keep only current one at FTP server.

#!/bin/bash

#define parameters: HOST=‘ftp.hostname.com’ USER=‘username’ PASSWD=‘password’ STARI=`cat /root/scripts/backup/stari` FILE=/root/scripts/backup/`date +%d-%m-%Y`-domain.tgz FILE2=`echo $FILE | awk -F"/" ‘{print $5}’`

#tar files: [...]

Zimbra backup script

Ovo je jedna bash skripta za backup mailova koji su se prethodno bekapovali kroz Zimbru. Pozdrazumevani setup je takav da postoji backup server, sa “backup” userom koji je kreiran tako da sa Zimbra servera možemo da se ulogujemo bez username/passworda (koristeći samo ssh ključeve). Tutorial za ovo (kako podesiti da 2 servera komuniciraju preko ssh [...]

Linux bash scripting part 1

In this script we will show how to create hard links and how to show all files with same i-node which we want.

$ touch file —–> this will create empty file “file” $ echo “test” > file —–> this will put “test” into “file” $ ls -li —–> this will list inode number of [...]