Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Tuesday, June 18, 2019

Linux: Compare if two files are the same

Quick script I wrote in my .bashrc to check if two files are the same:


#md5sum
function md5comp()
{
    a=$(md5sum $1 | awk '{print $1}')
    b=$(md5sum $2 | awk '{print $1}')
    echo "Comparing $1 and $2"
    [ "$a" = "$b" ] && echo  "Equal" || echo "Not Equal"


}

Monday, June 17, 2019

Linux: How to tar only selected folders and files

Step 1: Select the files and prepare a list.

I do this with a simple function in my .bashrc script:

$> cat >> ~/.bashrc
99 function cscopesetup()
100 {
101     rm cscope.files;


102
103     echo "Populating filenames...";
104     find $SRC/folder1/ -iname "*.c" -print >> cscope.files #folder1
105     find $SRC/folder9/ -iname "*.h" -print >> cscope.files #folder9
106     echo "Driver done"
107 }