Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ $# -ne 3 ]
- then
- echo "USAGE: `basename $0` src dst some_file.txt"
- exit 1
- fi
- if [ ! -d $1 ]
- then
- echo "Imenikot prosleden kako argument ne postoi"
- exit 1
- fi
- if [ -d $2 ]
- then
- rm $2
- fi
- mkdir $2
- if [ -f $3 ]
- then
- rm $3
- fi
- touch $3
- #get all files from source folder
- FILES=`ls -R $1 | grep ^- | awk 'print $10'`
- for file in $FILES
- do
- #change their name
- file_name=`echo $file | sed -e "s/\..*$//" -e "s/\'/'/_/"`
- file_extension=`echo $file | awk -F. 'print $NF'`
- sodrzina_file=`cat $file`
- #get sodrzina from the file we wanna move
- FILES2=`ls -R $2 | grep ^- | awk 'print $10'`
- #get all the moved files
- for file2 in $FILES2
- do
- sodrzina_file2=`cat $file2`
- #check if the file we are about to move happens to have same sodrzina with some of the moved
- if [ "$sodrzina_file" == "$sodrzina_file2" ]
- then
- echo "Fajlovite ${1}${file} i ${2}${file2} imaat ista sodrzina" >> $3
- fi
- done
- #move and rename
- mv ${1}${file} ${2}${file}
- mv ${2}${file} ${2}${file_name}.${file_extension}
- done
- #output
- cat $3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement