Can anybody explain me what does this script in each line?I can not run this because I think the syntax is incorrect.#! /bin/bashv=`echo $@|gawk '{print $NF}'`if[-d $v];thenfor v2 in $@;doif test $2 != $v;thenln $v2 $v/$v2rm $v2fidone
GAWK script explained
awk;gawk
Most of it is shell, and that's incorrect because of missing blanks on the first if-statement.  Alsothe first if-statement lacks a balancing fithe $@ should be quoted $@the $2 probably should be $v2The -d test anyway is suspect, since gawk should be printing a number (not a directory name). Still, you could be testing for a directory named for a number...As suggested in a comment, if you made those corrections, the script would try to remove everything that is not the same as the last parameter of the script, and make link to those removed files under the directory named by the final parameter.  (Just using mv would be more straightforward).Here's a suggested fixed script:#! /bin/bashv=`echo $@|gawk '{print $NF}'`if [ -d $v ];then  for v2 in $@;do    if test $v2 != $v;then      ln $v2 $v/$v2      rm $v2    fi  donefi