Need somme help with shell scripting plz I tried to uncomment fonction by pair in a script, let me explain : I have a text file with commented lines, with a shell script a created a fonction list and uncomment the line with the fonctions we choose. But some of these fonctions have a dependencies of another fonction For example :
text file ` #!/bin/sh ###====================================================================
--- Choose fonctions
###==================================================================== ###execution des fonctions de calnuit sans modifier le standard ###fonction 1### #some fonction 1 ###fonction 2### #some fonction 2 ###fonction 2### #some fonction 2 ###fonction 3### #some fonction 3 ###fonction 4### #some fonction 4 ###fonction 5### #some fonction 5 ###fonction 6### #some fonction 6 `
Fonction list
- fonction 3) fonction 5) fonction 7) fonction
- fonction 4) fonction 6) fonction 8) Finished
choose fonction to activate:
So actually i have to choose all the fonction i want to uncomment but somme of these depends of each other For example fonction 1 stop service1 and fonction 2 start service1 So i want if i choose fonction 1 automaticly it uncomment also fonction 2
Here the actual code
```
#!/bin/bash
PS3=$'\n\nchoose fonction to activate: '
options=$(grep -v '###' fonction_list.txt | awk '{ print $2}')
# Variable to store fonction choice
choices=()
select choice in $options Finished
do
# Stop choosing on this option
[[ $choice = Finished ]] && break
# Append the choice to the array
choices+=( "$choice" )
echo "$choice, Quel(s) autre(s) fonction(s) pour BATCH?"
done
# Construction du calnuit Batch
printf "Activation des fonctions de calnuit Batch: "
for choice in "${choices[@]}"
do
sed -i '/pattern '$choice'/s/^#*//g' fonction_list.txt
cp -f fonction_list.txt fonction_list.sh
chmod +x fonction_list.sh
done
```
Thanks you for your help