Hack The Sec - Leading Resource Of Linux Tutorial
Shell Script : Find All Zip / Rar Files Then Unzip / Unrar

Shell Script : Find All Zip / Rar Files Then Unzip / Unrar

Find All Zip / Rar Files Then Unzip / Unrar


We must first install and enable RPMForge repository under Linux systems to install Unrar and Rar command-line applications. We have provided RPMForge repositories for RHEL/CentOS 6/5/4 distributions. By defaultRPMForge repository already shipped with Fedora 17-12 systems, So fedora user’s don’t need to install it again

For RHEL/CentOS 6/5/4 – 32-Bit OS
## RHEL/CentOS 6 32-Bit ##
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.i686.rpm

## RHEL/CentOS 5 32-Bit ##
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.i386.rpm

## RHEL/CentOS 4 32-Bit ##
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-1.el4.rf.i386.rpm
# rpm -Uvh rpmforge-release-0.5.2-1.el4.rf.i386.rpm
For RHEL/CentOS 6/5/4 – 64-Bit OS
## RHEL/CentOS 6 64-Bit ##
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

## RHEL/CentOS 5 64-Bit ##
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

## RHEL/CentOS 4 64-Bit ##
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el4.rf.x86_64.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el4.rf.x86_64.rpm

Note: - For unrar command you have to install the command like this - yum install unrar for centos/REDHAT and FOR Ubuntu Debian - sudo apt-get install unrar-free


After That copy the shell script bellow and save it as hackthesec.sh

#!/bin/bash

list=`find /home/hackthesec/ -type f -name "*.rar"`

for line in $list; do

DEST=${line%/*}

unrar x $line $DEST

done


RUN-Shell Script Output

[root@go ~]# sh find.sh

UNRAR 5.00 beta 3 freeware      Copyright (c) 1993-2013 Alexander Roshal


Extracting from /home/hackthesec/shell.rar

Extracting  /home/hackthesec/find.sh   OK
All OK
[root@go ~]#


H

About the author

I am a Linux Administrator and Security Expert. Through this site I share Linux tutorials, hardening guides and security news.

Comments