Headlines
Loading...
Program in UNIX - File copy

Program in UNIX - File copy

A shell script receives even number of filenames. Suppose four filenames are supplied then the first file should get copied into second file, the third file should get copied into fourth file, and so on. If odd number of filenames are supplied then no copying should take place and an error message should be displayed.
if [ `expr $# % 2` -eq 0 ]
then
        while [ $# -gt 0 ]
        do
                cp $1 $2
                shift 2
        done
else
        echo " files cannot be copied ..."
        echo " enter only even number of filenames..."
fi
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***