Thouraya Sboui Thouraya Sboui - 3 years ago 121
Linux Question

erreur commande cut script shell

while i want to execute this script, the execution was blocked at the cut command and the man cut was displayed

the script code

#!/bin/bash

for i in `cat newcontext` ;do

var1=`cut –f1 –d" " $i`
var2=`cut –f2 –d" " $i`

if [ $var2 = false ];then

for j in `cat adaptrules`;do

c=`cut -f1 -d" " $j`
cc=`cut -f2 -d" " $j`

if [ $c = $var1 ];then
r=$cc
fi

done

sed /$var1/d currentconfig>>newconfig

else

for k in `cat adaptrules`;do
var3=`cut –f1 –d" " $k`
var4=`cut –f2 –d" " $k`

if [ $var3 = $var1 ];then
action=$var4
fi
done
cat $action >> newconfig
fi
done

Answer Source

You would need to execute the cut command with example:

var1=$(cut -f1 -d " " <<< $i)

You are trying to execute the cut command as if $i contains a filename when it actually contains text.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download