Skip to main content
Tweeted twitter.com/StackUnix/status/980323614892453888
edited body
Source Link
GAD3R
  • 69.9k
  • 32
  • 147
  • 216

Currently, iI am struggling getting 2 codes working in my bash script. They both work seperatelyseparately, but once they are both in the code, they don't.

var=$(cat /sys/block/vda/queue/rotational 2>/dev/null || cat /sys/block/sda/queue/rotational 2>/dev/null)
dtype='nil'
if [ $var = 0 ]; then
dtype=' SSD '
elif [ $var = 1 ]; then
        dtype=' HDD '
fi


var1=$(lsmod | grep kvm | awk 'NR==1{print $3}'  2>/dev/null)
vtype = 'no'
if [ $var1 = 0 ]; then
        vtype=' no '
else
    vtype = 'yes'
fi

printf '$dtype' '$vtype'
echo $dtype $vtype

First variable var is supposed to hold the value of rotational file. Asks 0 is for SSD and 1 is for HDD.

The second variable var1 checks if virtualization is present in your machine. If the number it holds is 0, then vtype is set to no, if its something else, then vtype is set to yes. These commands work perfectly, if i do them on different code files. But i need them both together. Any suggestions?

Currently, i am struggling getting 2 codes working in my bash script. They both work seperately, but once they are both in the code, they don't.

var=$(cat /sys/block/vda/queue/rotational 2>/dev/null || cat /sys/block/sda/queue/rotational 2>/dev/null)
dtype='nil'
if [ $var = 0 ]; then
dtype=' SSD '
elif [ $var = 1 ]; then
        dtype=' HDD '
fi


var1=$(lsmod | grep kvm | awk 'NR==1{print $3}'  2>/dev/null)
vtype = 'no'
if [ $var1 = 0 ]; then
        vtype=' no '
else
    vtype = 'yes'
fi

printf '$dtype' '$vtype'
echo $dtype $vtype

First variable var is supposed to hold the value of rotational file. Asks 0 is for SSD and 1 is for HDD.

The second variable var1 checks if virtualization is present in your machine. If the number it holds is 0, then vtype is set to no, if its something else, then vtype is set to yes. These commands work perfectly, if i do them on different code files. But i need them both together. Any suggestions?

Currently, I am struggling getting 2 codes working in my bash script. They both work separately, but once they are both in the code, they don't.

var=$(cat /sys/block/vda/queue/rotational 2>/dev/null || cat /sys/block/sda/queue/rotational 2>/dev/null)
dtype='nil'
if [ $var = 0 ]; then
dtype=' SSD '
elif [ $var = 1 ]; then
        dtype=' HDD '
fi


var1=$(lsmod | grep kvm | awk 'NR==1{print $3}'  2>/dev/null)
vtype = 'no'
if [ $var1 = 0 ]; then
        vtype=' no '
else
    vtype = 'yes'
fi

printf '$dtype' '$vtype'
echo $dtype $vtype

First variable var is supposed to hold the value of rotational file. Asks 0 is for SSD and 1 is for HDD.

The second variable var1 checks if virtualization is present in your machine. If the number it holds is 0, then vtype is set to no, if its something else, then vtype is set to yes. These commands work perfectly, if i do them on different code files. But i need them both together. Any suggestions?

Reformatted code and tries to enhance the explaining test a bit
Source Link

Currently, i am struggling getting 2 codes working in my bash script. They both work seperately, but once they are both in the code, they don't.

var=$(cat /sys/block/vda/queue/rotational 2>/dev/null || cat /sys/block/sda/queue/rotational 2>/dev/null)
dtype='nil'
if [ $var = 0 ]; then
dtype=' SSD '
elif [ $var = 1 ]; then
        dtype=' HDD '
fi


var1=$(lsmod | grep kvm | awk 'NR==1{print $3}'  2>/dev/null)
vtype = 'no'
if [ $var1 = 0 ]; then
        vtype=' no '
else
    vtype = 'yes'
fi

printf '$dtype' '$vtype'
echo $dtype $vtype

first "var"First variable var is supposed to hold the value of rotational file. Asks 00 is for SSD and 11 is for HDD.

The second "var1"variable var1 checks if virtualization is present in your machine. If the number it crepsholds is 00, then novtype is set to no, if its something else, then yesvtype is set to yes. These commands work perfectly, if i do them on different code files. But i need them both together. Any suggestions?

Currently, i am struggling getting 2 codes working in my bash script. They both work seperately, but once they are both in the code, they don't.

var=$(cat /sys/block/vda/queue/rotational 2>/dev/null || cat /sys/block/sda/queue/rotational 2>/dev/null)
dtype='nil'
if [ $var = 0 ]; then
dtype=' SSD '
elif [ $var = 1 ]; then
        dtype=' HDD '
fi


var1=$(lsmod | grep kvm | awk 'NR==1{print $3}'  2>/dev/null)
vtype = 'no'
if [ $var1 = 0 ]; then
        vtype=' no '
else
    vtype = 'yes'
fi

printf '$dtype' '$vtype'
echo $dtype $vtype

first "var" is supposed to hold the value of rotational file. Asks 0 is for SSD and 1 is for HDD.

second "var1" checks if virtualization is present in your machine. If the number it creps is 0, then no, if its something else, then yes. These commands work perfectly, if i do them on different code files. But i need them both together. Any suggestions?

Currently, i am struggling getting 2 codes working in my bash script. They both work seperately, but once they are both in the code, they don't.

var=$(cat /sys/block/vda/queue/rotational 2>/dev/null || cat /sys/block/sda/queue/rotational 2>/dev/null)
dtype='nil'
if [ $var = 0 ]; then
dtype=' SSD '
elif [ $var = 1 ]; then
        dtype=' HDD '
fi


var1=$(lsmod | grep kvm | awk 'NR==1{print $3}'  2>/dev/null)
vtype = 'no'
if [ $var1 = 0 ]; then
        vtype=' no '
else
    vtype = 'yes'
fi

printf '$dtype' '$vtype'
echo $dtype $vtype

First variable var is supposed to hold the value of rotational file. Asks 0 is for SSD and 1 is for HDD.

The second variable var1 checks if virtualization is present in your machine. If the number it holds is 0, then vtype is set to no, if its something else, then vtype is set to yes. These commands work perfectly, if i do them on different code files. But i need them both together. Any suggestions?

added 4 characters in body
Source Link
TheSebM8
  • 471
  • 3
  • 9
  • 19

Currently, i am struggling getting 2 codes working in my bash script. They both work seperately, but once they are both in the code, they don't.

var=$(cat /sys/block/vda/queue/rotational 2>/dev/null || cat /sys/block/sda/queue/rotational 2>/dev/$null)
dtype='nil'
if [ $var = 0 ]; then
dtype=' SSD '
elif [ $var = 1 ]; then
        dtype=' HDD '
fi


var1=$(lsmod | grep kvm | awk 'NR==1{print $3}'  2>/dev/null)
vtype = 'no'
if [ $var1 = 0 ]; then
        vtype=' no '
else
    vtype = 'yes'
fi

printf '$dtype' '$vtype'
echo $dtype $vtype

first "var" is supposed to hold the value of rotational file. Asks 0 is for SSD and 1 is for HDD.

second "var1" checks if virtualization is present in your machine. If the number it creps is 0, then no, if its something else, then yes. These commands work perfectly, if i do them on different code files. But i need them both together. Any suggestions?

Currently, i am struggling getting 2 codes working in my bash script. They both work seperately, but once they are both in the code, they don't.

var=$(cat /sys/block/vda/queue/rotational 2>/dev/null || cat /sys/block/sda/queue/rotational 2>/dev/$
dtype='nil'
if [ $var = 0 ]; then
dtype=' SSD '
elif [ $var = 1 ]; then
        dtype=' HDD '
fi


var1=$(lsmod | grep kvm | awk 'NR==1{print $3}'  2>/dev/null)
vtype = 'no'
if [ $var1 = 0 ]; then
        vtype=' no '
else
    vtype = 'yes'
fi

printf '$dtype' '$vtype'
echo $dtype $vtype

first "var" is supposed to hold the value of rotational file. Asks 0 is for SSD and 1 is for HDD.

second "var1" checks if virtualization is present in your machine. If the number it creps is 0, then no, if its something else, then yes. These commands work perfectly, if i do them on different code files. But i need them both together. Any suggestions?

Currently, i am struggling getting 2 codes working in my bash script. They both work seperately, but once they are both in the code, they don't.

var=$(cat /sys/block/vda/queue/rotational 2>/dev/null || cat /sys/block/sda/queue/rotational 2>/dev/null)
dtype='nil'
if [ $var = 0 ]; then
dtype=' SSD '
elif [ $var = 1 ]; then
        dtype=' HDD '
fi


var1=$(lsmod | grep kvm | awk 'NR==1{print $3}'  2>/dev/null)
vtype = 'no'
if [ $var1 = 0 ]; then
        vtype=' no '
else
    vtype = 'yes'
fi

printf '$dtype' '$vtype'
echo $dtype $vtype

first "var" is supposed to hold the value of rotational file. Asks 0 is for SSD and 1 is for HDD.

second "var1" checks if virtualization is present in your machine. If the number it creps is 0, then no, if its something else, then yes. These commands work perfectly, if i do them on different code files. But i need them both together. Any suggestions?

Source Link
TheSebM8
  • 471
  • 3
  • 9
  • 19
Loading