The expensive, but easy to remember route:
a=$(echo "$oktet2" | cut -c1)
b=$(echo "$oktet2" | cut -c2)
c=$(echo "$oktet2" | cut -c3)
or:
read a b c << EOF
$(echo "$oktet2" | fold -w1 | xargs)
EOF
or something exotic
{
read a
read b
read c
} << EOF
$(
fold -w1 << EOF2
$oktet2
EOF2
)
EOF
Thanks to everyone for all the support .. I do not know which shell I use.
Operating system Kali Linux (Debian) 2.6
I did what I wanted. I made it on the quilt that "Scrutinizer" said
#!/usr/bin/env bash
#!/bin/bash
IFS="." read OCT1 OCT2 OCT3 OCT4
a=$(echo "$OCT2" | cut -c1)
b=$(echo "$OCT2" | cut -c2)
c=$(echo "$OCT2" | cut -c3)
echo $a
echo $b
echo $c
its work... again thanks everybody
Debian means you probably use DASH, I think. Which sadly makes cut one of the easier options.
Hopefully DASH will catch up to the 90's one of these days.
Yes but it only means that /bin/sh
points to dash
. bash
should be readily available, and appears to be used, according to the shebang ( !#
), but it depends how the script is being called. I cannot make out the exact version of the Kali Linux in question...
@OP. Can you post :
bash --version
cat /etc/*release
How do you run the script?