Browsing Tag Bash

8 Post Found in Bash Tag

Bash script to Switch PHP Versions in Ubuntu

Bash script to Switch PHP Versions in Ubuntu

I found myself constantly needing to switch PHP versions in my development environment based on the projects I work on. I wanted to have a simple way to switch php versions and all the tools I found were heavy weight or to complicated for my purpose. So I wrote a simple bash script which provides

Continue reading

My Favorite Bash aliases that increases productivity

My Favorite Bash aliases that increases productivity

Intoduction

I have been using Linux (Ubuntu) well over a decade and I fell in love with command line interface which gives you more control and power over the system.Any one who loves linux would probably agree with me. The more you use command line, you will tend to notice that you use some

Continue reading

how to migrate from one ubuntu machine to another

Step 1: Gather details on packages installed on the source machine

To get the list of all packages installed on the machine. The following command can be used. This one line script will get all the installed package and store them into a file.


$ sudo dpkg --get-selections | sed "s/.*deinstall//" | sed "s/install$//g" | sed

Continue reading

Split and Merge file using dd command

Split and Merge file using dd command

dd command is one of the powerful utility in Linux and should be in every hacker's arsenal. dd command is used to manipulate binary files directly. dd is the tool used to write disk headers, boot records. The command is mostly used to copy / clone / backup / restore entire hard disk or partitions. Any Wrong usage

Continue reading

Open VPN config file split and merge

Open VPN config file split and merge

I am a big fan of OpenVPN and I use OpenVPN for both work and personal purposes. Using VPN is an integral part for me as I rely on it to manage my VPC at work and also to manage my privacy online. I use OpenVPN network manager to connect with the VPN in my

Continue reading

Delete stale files by last accessed time and created time (Bash)

Delete stale files by last accessed time and created time (Bash)

I implemented file based caching on one of my projects to cache large number of responses which are CPU and memory intensive. The file caching worked as a charm at start but soon I started to hit the storage capacity of the web server. So I wanted a script that can be configured in cron

Continue reading

Bash Cheat Sheet - File operation

Bash Cheat Sheet - File operation

Get filename with file extension


FULLFILENAME=$(basename $FILE)

Get filename without file extension


FILENAME="${FILE%.*}"

Get extension from filename


EXTENSION="${FILE##*.}"

Get MIME type of the given file


MIME_TYPE=`file --brief --mime-type "$FILE"`

Get current directory of the script

Get the full directory name of the script no matter where it is being called

Continue reading