• 🏠 Home
  • 🧰 Online Generators
  • 📰 Blog
  • 🔎 Search
  • 📧 Contact
  • 📘 Guestbook
  • 🗞️ News
  • 💰 Support
  • ℹ️ Info: The website has been modernized to improve readability and smartphone compatibility. Feel free to report any bugs using the contact form

    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



    (c) 2005-2025 Jérôme DESMOULINS
    Data privacy