I have a problem with my if. I have try a lot of things but I don't understand why it's not working. this is a bash script. The algo seems correct but the if doesn't work and I don't know why... If you can help me, it should be cool. The way of this code is :
the first word of line of the txt file from param $0 is the name of directory and the script will create it
the second word is the template from the current directory
The third word is the name of the destination file.
The fourth word is the name and the fifth is the firstname
the end of the line should be at the end of the file
this is the code:
#!/bin/bash while read line do first=$( echo $line | awk '{print $1}') second=$( echo $line | awk '{print $2}') template=$( echo $line | awk '{print $3}') name=$( echo $line | awk '{print $4}') surname=$( echo $line | awk '{print $5}') var =wc -w $line mkdir $first touch $template $second > $template if[$var -gt 5] then while $i-gt $var do if [$i - le 5] then elif $word=$( echo $line | awk '{print $i}') $word>$template fi while read line do if[$line -eq "XXNOMXX"] then $line=$name fiif[$line -eq "XXPRENOMXX"] then $line=$surname fi done <$template mv $template $first done < $0
sample launch: /script.sh file.txt
sample param in file:
Test1 templ1.txt data.txt Dupont Jean Hello World
Test2 templ2.txt data.txt beebleboxzaphod the answer if forty-two
Aucun commentaire:
Enregistrer un commentaire