Swap - Reverse two file names


Overview

    Sometimes having to reverse two file names. To do this, it is possible to add a function to the shell. This function is called swap.

Usage

    To use Swap:
      swap file1 file2
    The content of file2 will be on file1, and vice versa.

    Implementation

      To do this, simply place the lines:
        	function swap()         # swap 2 filenames around
        	{
        		local TMPFILE=tmp.$$
        		mv "$1" $TMPFILE
        		mv "$2" "$1"
        		mv $TMPFILE "$2"
        	}
        
      on ~/.bashrc file.

       

      Go back

 Actions

 Language:
 RSS flow: